redis / lettuce

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
https://lettuce.io
MIT License
5.39k stars 970 forks source link

Sentinel support should be able to autodiscover additional Sentinel nodes #1168

Open mikebell90 opened 4 years ago

mikebell90 commented 4 years ago

Refer to #1144 for original impetus.

Currently Lettuce provides a RedisURI with a list of Sentinel nodes.

My request is there is a way to create a shared SentinelTopologyProvider that caches this list, and adds/removes dynamically additional Sentinel nodes.

Example: I connect with 3 sentinel nodes, but entire cluster is 100 sentinel nodes. In the background Lettuce . would

a) After a delay (10 seconds suggested by Redis . Sentinel documents), a refresh of all Sentinel nodes is made. Additionally discovered ones are added, lost ones (sentinel reset) are removed.

b) Subscribe to the pub-sub topic and watch for new sentinel nodes added/removed (I'm assuming that information is available)

@mp911de brings up concerns of complexity and of security. Obviously the former is inarguable, though if it works like I think it would, it would be no more complex than the standard master/replica refresh. As for security, that's why it's an option, not required.

mikebell90 commented 4 years ago

Further discussion of reasoning

@mp911de is of course correct that you can try to choose a reasonable number of seed nodes across availability groups and must do so for successful connection to begin with.

However a long running cluster may undergo maintenance. It's a bad thing IMO if the Sentinel topology is . not refreshed at the same time.

mp911de commented 4 years ago

We should find an approach that balances usability vs. extensibility. As a first step, we could make the building blocks (such as SentinelConnector) public so anyone that wants customization beyond what we already provide is able to plug their own functionality together.