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.35k stars 960 forks source link

Redis Multilevel Master Slave Replication #1042

Open omjego opened 5 years ago

omjego commented 5 years ago

Bug Report

Current Behavior

Hi, I'm not sure if it's even a bug or I'm missing something. I have a multilevel master-level redis setup, where I have got a single master at level 0, then it has multiple slaves (level 1), and nodes on level 1 have got there own slaves and two more such levels. This whole thing was done due to some reasons which I'm not aware of. Issue 1 In order to create LettuceConnectionFactory for this setup, it suffices to pass RedisStandaloneConfiguration of master/slave and along with that LettucePoolingClientConfiguration where I set ReadFrom to NEAREST. But when I pass host: port of any node below level 1 it doesn't work, it gives following error when I hit actuator/health endpoint

myLettuceConnectionFactory": { "status": "DOWN", "details": { "error": "org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: Cannot determine a node to read (Known nodes: []) with setting io.lettuce.core.ReadFromImpl$ReadFromNearest@72b18351" } }

But it works really fine when I put any node from level 0 or level 1 as a seed. Putting host of any node after level 1 fails.

Issue 2 Considering the above example here also, even if I give host: port of the ultimate master as initial seed, Lettuce wasn't able to discover the whole topology and missed out on nodes below level 1.

In the dump below: Level 2 node: 172.24.200.33 Level 1 node: 172.16.201.146 Level 0 node: 172.16.201.145

I've added the topology discovery dump here

mp911de commented 5 years ago

Lettuce does not support discovery with multi-level replication. It supports only a single level (master-replica).

omjego commented 5 years ago

Are there any plans for implementing this feature in near future ?

omjego commented 5 years ago

Is there any way to find out which nodes it has discovered already on a running server? Probably using something like actuator.

mp911de commented 5 years ago

Are there any plans for implementing this feature in near future ?

No. This is something that would increase complexity by orders of magnitude.

You could specify all nodes in a Collection<RedisURI>. Node discovery is not exposed through the public API.

omjego commented 5 years ago

To be very specific I want to use redis nodes from level 2 in my app. So as a workaround, I'm using StaticMasterSlaveConfig, where I've specified root master node and few of the slave nodes in level 2 as the initial configuration. And it seems to be working. Wanted to know if this is the right way to do it or there is a better solution to this problem?

mp911de commented 5 years ago

Wanted to know if this is the right way to do it

This is the appropriate way. Alternatively, if you have just a single node, then you could also connect directly to that node via RedisClient assuming that this is a standalone node.

tishun commented 2 months ago

Is this issue still relevant?