lettuce icon indicating copy to clipboard operation
lettuce copied to clipboard

Redis Multilevel Master Slave Replication

Open omjego opened this issue 5 years ago • 7 comments

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

  • Lettuce version: 5.1.6.RELEASE
  • Redis version: 4.0.1

omjego avatar May 24 '19 05:05 omjego

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

mp911de avatar May 24 '19 06:05 mp911de

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

omjego avatar May 24 '19 06:05 omjego

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

omjego avatar May 24 '19 11:05 omjego

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.

mp911de avatar May 24 '19 12:05 mp911de

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?

omjego avatar May 27 '19 07:05 omjego

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.

mp911de avatar May 27 '19 09:05 mp911de