Does RedissonRedLock support Redis cluster Master/Slave mode?
See original GitHub issueIn this issuehttps://github.com/redisson/redisson/issues/1333#issuecomment-371817371 I found that RedissonRedLock supports Redis cluster mode. In the Redlock algorithm https://redis.io/topics/distlock,I don’t think it supports Master/Slave mode.The description is:
In the distributed version of the algorithm we assume we have N Redis masters. Those nodes are totally independent, so we don’t use replication or any other implicit coordination system.
For example: The Redis cluster 1 is as follows: Master1 Slave1 Master2 Slave2 Master3 Slave3
The Redis cluster 2 is as follows: Master1 Master2 Master3
I am troubled. Does it support type of Redis cluster 1 ? .If it supports then how do I add a configuration, whether the master and slave are added or only the master configuration is added. For example : Add as type1
Config config = new Config();
config.useClusterServers().addNodeAddress(Master1, Master2,Master3, Slave1,Slave2, Slave3);
RedissonClient redisson = Redisson.create(config);
RLock lock1 = redisson.getLock(lockName + "1");
RLock lock2 = redisson.getLock(lockName + "2");
RLock lock3 = redisson.getLock(lockName + "3");
RLock lock4 = redisson.getLock(lockName + "4");
RLock lock5 = redisson.getLock(lockName + "5");
RLock lock6 = redisson.getLock(lockName + "6");
Add as type2
Config config = new Config();
config.useClusterServers().addNodeAddress(Master1, Master2,Master3);
RedissonClient redisson = Redisson.create(config);
RLock lock1 = redisson.getLock(lockName + "1");
RLock lock2 = redisson.getLock(lockName + "2");
RLock lock3 = redisson.getLock(lockName + "3");
Add as type3
Config config = new Config();
config.useClusterServers().addNodeAddress(Master1, Master2,Master3, Slave1,Slave2, Slave3);
RedissonClient redisson = Redisson.create(config);
RLock lock1 = redisson.getLock(lockName + "1");
RLock lock2 = redisson.getLock(lockName + "2");
RLock lock3 = redisson.getLock(lockName + "3");
Which type should I choose,or they are all wrong?
Redis version
3.x
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
@mrniko I know it. I am concerned about is that the master node is hung. When switching from the node, it will cause the red lock to be lost, resulting in a deadlock. E.g: (1) If the cluster has 5 active and standby nodes, process P1 requests to acquire lock lock1 (on Node Master1), lock2 (on Node Master2), lock3 (on Node Master3), lock4 (on Node Master4), lock5 (on Node Master5) ). Finally got lock1, lock2, lock3. Because lock4, lock5 is obtained by P2. (2) Master1 hangs, switches Slave1, and loses lock1. (3) Process P2 requests to acquire locks lock1, lock2, lock3, lock4, lock5, acquire lock lock1 (on Node Slave1), lock4 (on Node Master4), lock5 (on Node Master5). lock2 and lock3 fail to be acquired by P1. . (4) P1, P2 have acquired the lock According to the algorithm, I understand that there should be no slave nodes. Is my understanding correct?
You can use predetermined value in the key name and use
{}
to force the key slot calculation onto your desired node.