Two serious issues
1.Sentinel not support auth password.(I have solve this problem) 2.When redis sentinel occur failover,redisson can not failover to new master automatic。
1.Sentinel not support auth password.(I have solve this problem)
fixed
- When redis sentinel occur failover,redisson can not failover to new master automatic
Could you provide more details about this case? Sentinel not switching master at a moment it waits down-after-milliseconds
Have you seen "+switch-master ..." command in your sentinel log?
@lianghaijian can't reproduce it
Wait a moment,I will reproduce it,and provide more details.
My test code:
@Test
public void testSentinelWithAuth() throws InterruptedException {
Config config = new Config();
config.useSentinelConnection().setPassword("foobared")
.setMasterName("mymaster")
.addSentinelAddress("192.168.27.111:26379", "192.168.27.112:26379");
Redisson redisson = Redisson.create(config);
final List<User> list = redisson.getList("cms_list");
Runnable r = new Runnable() {
@Override
public void run() {
long begin = System.currentTimeMillis();
for(int i=0;i<10000;i++){
try{
list.add(new User());
}catch (Exception e){
e.printStackTrace();
}
}
System.out.println("coast:" + (System.currentTimeMillis() - begin) / 1000);
}
};
List<Thread> threads = new ArrayList<Thread>(Runtime.getRuntime().availableProcessors()*2);
for(int i=0;i<Runtime.getRuntime().availableProcessors()*2;i++){
Thread t = new Thread(r);z
t.start();
threads.add(t);
}
for(Thread t : threads){
t.join();
}
}
After i killed the master redis server process,redis sentinel log:
[19545] 14 Jul 11:17:03.882 # +failover-end master mymaster 192.168.27.111 6379
[19545] 14 Jul 11:17:03.882 # +switch-master mymaster 192.168.27.111 6379 192.168.27.112 6379
[19545] 14 Jul 11:17:03.882 * +slave slave 192.168.27.111:6379 192.168.27.111 6379 @ mymaster 192.168.27.112 6379
[19545] 14 Jul 11:17:08.969 # +sdown slave 192.168.27.111:6379 192.168.27.111 6379 @ mymaster 192.168.27.112 6379
list.add(new User()); will throw timeout exception,next loop can not get new master connection.
com.lambdaworks.redis.RedisException: Command timed out
at com.lambdaworks.redis.RedisAsyncConnection.await(RedisAsyncConnection.java:1195)
at com.lambdaworks.redis.RedisConnection.await(RedisConnection.java:852)
at com.lambdaworks.redis.RedisConnection.rpush(RedisConnection.java:489)
at org.redisson.RedissonList.addAll(RedissonList.java:134)
at org.redisson.RedissonList.add(RedissonList.java:85)
at org.redisson.SentinelAuthTest$1.run(SentinelAuthTest.java:48)
at java.lang.Thread.run(Thread.java:744)
My computer :2.7 GHz Intel Core i7 16 GB 1600 MHz DDR3, The test result is not satisfactory,an average of 750 times per second
It's a bug,when a connection can not be used,it always be return back to pool
@Override
public boolean addAll(Collection<? extends V> c) {
RedisConnection<String, Object> conn = connectionManager.connectionWriteOp();
try {
conn.rpush(getName(), c.toArray());
return true;
} finally {
connectionManager.releaseWrite(conn);
}
}
Because the pool have connections,i can't get a new master connection from pool
@Override
public <K, V> RedisConnection<K, V> connectionWriteOp() {
acquireMasterConnection();
RedisConnection<K, V> conn = masterConnections.poll();
if (conn != null) {
return conn;
}
conn = masterClient.connect(codec);
if (config.getPassword() != null) {
conn.auth(config.getPassword());
}
return conn;
}
Oh, could you update from master? i think i fixed this issue. All info about master server now in holds in one entry-object.
here is my change - https://github.com/mrniko/redisson/commit/9bd40f1363eae2f499fcfc9ec7ee62bfbc22f1e7
Sorry,i will update and try immediately
com.lambdaworks.redis.RedisException: Command timed out
at com.lambdaworks.redis.RedisAsyncConnection.await(RedisAsyncConnection.java:1195)
at com.lambdaworks.redis.RedisConnection.await(RedisConnection.java:852)
at com.lambdaworks.redis.RedisConnection.rpush(RedisConnection.java:489)
at org.redisson.RedissonList.addAll(RedissonList.java:134)
at org.redisson.RedissonList.add(RedissonList.java:85)
at org.redisson.SentinelTest$1.run(SentinelTest.java:49)
at java.lang.Thread.run(Thread.java:744)
When redis occur failover,the exception above coast too much time,do you have any plan to resolve it.
Yes, i'll think how to resolve it. What about bug with master change?
The bug has been resolved, your solution is the same as I think, hahahaha.
What about exception handling how did you done it?
Try again a few times,if still failed,warning.I have seen your code,if a connection is closed,this connection can still return to the queue?I know in the lastest version jedis,jedis client close() will check if client is close before return to commons pool.
If channel enters to "Inactive" state then com.lambdaworks.redis.protocol.ConnectionWatchdog going to work.
Check the last commit. Did you mean this problem?
@lianghaijian i just complete operation auto-repeat for RedissonMap, you don't need to catch exceptions anymore then master or slave is down. Check it out ;)
I am facing same issue. One of the sentinels in my config is down and i can not start server as redisson always try to connect the last one in config.
@prarthanb
always try to connect the last one in config
and not the server which has down? it's never connects to sentinel which has down?