Skip to content

Commit

Permalink
Merge pull request #1784 from fluent/fix-heartbeat-handling-for-recovery
Browse files Browse the repository at this point in the history
out_forward: Rebuild weight array to apply server setting properly. fix #1772
  • Loading branch information
repeatedly committed Dec 13, 2017
1 parent 83600ed commit 5adb424
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/fluent/plugin/out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def rebuild_weight_array

r = Random.new(@rand_seed)
weight_array.sort_by! { r.rand }
p weight_array.map { |e| e.name }

@weight_array = weight_array
end
Expand Down Expand Up @@ -397,13 +398,17 @@ def on_timer
begin
#log.trace "sending heartbeat #{n.host}:#{n.port} on #{@heartbeat_type}"
if @heartbeat_type == :tcp
send_heartbeat_tcp(n)
if send_heartbeat_tcp(n)
rebuild_weight_array
end
else
@usock.send "\0", 0, Socket.pack_sockaddr_in(n.port, n.resolved_host)
end
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR, Errno::ECONNREFUSED
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR, Errno::ECONNREFUSED => e
# TODO log
log.debug "failed to send heartbeat packet to #{n.host}:#{n.port}", error: $!.to_s
log.debug "failed to send heartbeat packet to #{n.host}:#{n.port}", error: e.to_s
rescue => e
log.debug "unexpected error happen during heartbeat to #{n.host}:#{n.port}", error: e.to_s
end
if n.tick
rebuild_weight_array
Expand Down

0 comments on commit 5adb424

Please sign in to comment.