airbnb / synapse

A transparent service discovery framework for connecting an SOA
MIT License
2.07k stars 251 forks source link

Ensure watchers exist in ZookeeperDnsWatcher #334

Closed panchr closed 4 years ago

panchr commented 4 years ago

Summary

Fix race condition when starting up ZookeeperDnsWatcher. The race condition is that @dns will not exist by the time that @zk calls its reconfigure_callback, which in turn will call @dns.backends.

This was introduced in #333; since the ZK watchers will always discover first before completing start, they will always call reconfigure_callback on startup.

Testing

Previously during startup, this error was received when using ZookeeperDnsWatcher: E, [2020-08-31T09:42:40.828903 #8859] ERROR -- Synapse::Synapse: synapse: encountered unexpected exception #<NoMethodError: undefined method `backends' for nil:NilClass> in main thread

Now, Synapse starts up properly.

Reviewers

@austin-zhu