Skip to content

Commit

Permalink
Remove on_connected callback to avoid reconnect storm
Browse files Browse the repository at this point in the history
  • Loading branch information
anson627 committed Jun 13, 2019
1 parent c239c59 commit 1efa7b8
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions lib/synapse/service_watcher/zookeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,6 @@ def zk_connect
zk_cleanup
end

# handle session connected after reconnecting
# http://zookeeper.apache.org/doc/r3.3.5/zookeeperProgrammers.html#ch_zkSessions
@zk.on_connected do
log.info "synapse: ZK client has reconnected #{@name}"
# random backoff to avoid refresh at the same time
sleep rand(10)
# zookeeper watcher is one-time trigger, and can be lost when disconnected
# https://zookeeper.apache.org/doc/r3.3.5/zookeeperProgrammers.html#ch_zkWatches
@watcher.unsubscribe unless @watcher.nil?
@watcher = nil
watcher_callback.call
end

# the path must exist, otherwise watch callbacks will not work
statsd_time('synapse.watcher.zk.create_path.elapsed_time', ["zk_cluster:#{@zk_cluster}", "service_name:#{@name}"]) do
create(@discovery['path'])
Expand Down

0 comments on commit 1efa7b8

Please sign in to comment.