airbnb / synapse

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

Add retry logics for zookeeper get #284

Closed anson627 closed 5 years ago

anson627 commented 5 years ago

zookeeper get can return nil or throw timeout exception, when network is flaky or zookeeper is overloaded.

adding retry logics (by default 3 times with 5 second interval) can alleviate the problem.

if all retries failed, throw runtime error forcing the process to re-establish zookeeper connections.

@austin-zhu @ken-experiment

austin-zhu commented 5 years ago

also, remember to bump version

anson627 commented 5 years ago

This change LGTM.

Just want to get more context, when throw exceptions instead of swallowing them in the previous code, will it introduce any unexpected behaviors in caller functions?

The caller's behaviors stay the same. After retries several times specified by caller, it will still throw error.

However errors are handled by two callers inconsistently, based on original implementation, one would raise, the other would swallow. For that, I hesitate to change it yet, because I don't think I fully understand the intention.