-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Environments:
- spring-data-redis 2.2.0.RELEASE
- lettuce 5.2.0.RELEASE (with validateConnection and autoTopologyRefresh enabled - periodic and all triggers)
- redis 4.0.14 (3 masters, 3 slaves)
Issue:
When using RedisTemplate.execute(conn->conn.incrBy(key,delt)), I observed that some microservices PING a slave node before sending the INCR command to the correct master node.
Through debugging, I found the following logic: The PING command uses the defaultWriter because it has no parameters, unlike the INCR command which is routed to a specific master node.
- 2.2.0 RELEASE
Line 1210 in f9de805
((StatefulRedisClusterConnection) connection).sync().ping(); - 3.4.1
Line 1623 in b529e83
statefulClusterConnection.sync().ping(); - 5.2.0.RELEASE
return dispatch(commandBuilder.ping());// exclude CLIENT commands from cluster routing
if (args != null && !CommandType.CLIENT.equals(commandToSend.getType())) {- 6.5.1.RELEASE
return dispatch(commandBuilder.ping());// exclude CLIENT commands from cluster routing
if (args != null && !CommandType.CLIENT.equals(commandToSend.getType())) {I suspect this behavior is due to the routing logic shown above.
I've been searched Google for "spring-data-redis validateConnection ping" and "spring-data-redis validateConnection ping slave", and also searched for "validateConnection" in the issues, but found no relevant information.
Questions
- Is my analysis of the routing mechanism correct?
- Is it intended that validateConnection sends PING command through defaultWriter instead of using the same connection as the subsequent command?
I'm currently diving deeper into the source code. Any insights or confirmation would be greatly appreciated.