Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using RedisTemplate executePipeline , ping to all nodes #3122

Closed
gary258796 opened this issue Mar 21, 2025 · 1 comment
Closed

Using RedisTemplate executePipeline , ping to all nodes #3122

gary258796 opened this issue Mar 21, 2025 · 1 comment
Labels
for: external-project For an external project and not something we can fix

Comments

@gary258796
Copy link

I have deployed a Redis Cluster in my system with a configuration of 3 masters and 3 slaves, where all 6 nodes are on different machines.

And I have set up the following configuration, ensures that the system performs all read and write operations only through the master nodes, while the slave nodes are only used for data backup.
LettuceClientConfiguration.LettuceClientConfigurationBuilder lettuceClientConfigurationBuilder = LettuceClientConfiguration.builder(); lettuceClientConfigurationBuilder.readFrom(ReadFrom.MASTER);

And I have set up the following configuration of my RedisTemplate, which 'pingBeforeActivateConnection' is set to true.
ClusterClientOptions.Builder clusterClientOptionsBuilder = ClusterClientOptions.builder(); clusterClientOptionsBuilder.autoReconnect(true).pingBeforeActivateConnection(true);

I noticed that when using the redisTemplate.executePipelined command, it pings all Redis nodes. But why?

Other commands like opsForValue().get() and opsForList().rightPush() don’t ping all nodes.

This causes a problem when any machine is down because the ping is still executed, forcing my application to wait until the ping times out.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 21, 2025
@mp911de
Copy link
Member

mp911de commented Mar 21, 2025

RESP2:

1742545380.094068 [0 127.0.0.1:58250] "PING"
1742545380.096233 [0 127.0.0.1:58250] "CLIENT" "SETINFO" "lib-name" "Lettuce"
1742545380.096243 [0 127.0.0.1:58250] "CLIENT" "SETINFO" "lib-ver" "6.4.2.RELEASE/f4dfb40"
1742545380.098150 [0 127.0.0.1:58250] "CLIENT" "SETNAME" "lettuce#ClusterTopologyRefresh"
1742545380.098879 [0 127.0.0.1:58250] "CLUSTER" "NODES"
1742545380.098960 [0 127.0.0.1:58250] "INFO"
1742545380.106134 [0 127.0.0.1:58251] "PING"
1742545380.106783 [0 127.0.0.1:58251] "CLIENT" "SETINFO" "lib-name" "Lettuce"
1742545380.106797 [0 127.0.0.1:58251] "CLIENT" "SETINFO" "lib-ver" "6.4.2.RELEASE/f4dfb40"
1742545380.107511 [0 127.0.0.1:58251] "CLIENT" "SETNAME" "lettuce#ClusterTopologyRefresh"
1742545380.109587 [0 127.0.0.1:58251] "CLUSTER" "NODES"
1742545380.109663 [0 127.0.0.1:58251] "INFO"
1742545380.174457 [0 127.0.0.1:58259] "PING"
1742545380.175042 [0 127.0.0.1:58259] "CLIENT" "SETINFO" "lib-name" "Lettuce"
1742545380.175056 [0 127.0.0.1:58259] "CLIENT" "SETINFO" "lib-ver" "6.4.2.RELEASE/f4dfb40"
1742545380.175771 [0 127.0.0.1:58259] "DEL" "b"

RESP3

1742545504.365944 [0 127.0.0.1:60919] "HELLO" "3"
1742545504.369437 [0 127.0.0.1:60919] "CLIENT" "SETINFO" "lib-name" "Lettuce"
1742545504.369445 [0 127.0.0.1:60919] "CLIENT" "SETINFO" "lib-ver" "6.4.2.RELEASE/f4dfb40"
1742545504.371123 [0 127.0.0.1:60919] "CLIENT" "SETNAME" "lettuce#ClusterTopologyRefresh"
1742545504.371846 [0 127.0.0.1:60919] "CLUSTER" "NODES"
1742545504.371918 [0 127.0.0.1:60919] "INFO"
1742545504.379317 [0 127.0.0.1:60920] "HELLO" "3"
1742545504.380066 [0 127.0.0.1:60920] "CLIENT" "SETINFO" "lib-name" "Lettuce"
1742545504.380074 [0 127.0.0.1:60920] "CLIENT" "SETINFO" "lib-ver" "6.4.2.RELEASE/f4dfb40"
1742545504.380946 [0 127.0.0.1:60920] "CLIENT" "SETNAME" "lettuce#ClusterTopologyRefresh"
1742545504.382800 [0 127.0.0.1:60920] "CLUSTER" "NODES"
1742545504.382859 [0 127.0.0.1:60920] "INFO"
1742545504.467445 [0 127.0.0.1:60928] "HELLO" "3"
1742545504.467864 [0 127.0.0.1:60928] "CLIENT" "SETINFO" "lib-name" "Lettuce"
1742545504.467867 [0 127.0.0.1:60928] "CLIENT" "SETINFO" "lib-ver" "6.4.2.RELEASE/f4dfb40"
1742545504.468431 [0 127.0.0.1:60928] "DEL" "b"

I think what you're seeing is the difference between RESP2 and RESP3 handling. In RESP2, Ping before activate is issued as PING command while RESP3 uses on the HELLO command.

Once a connection is established, you won't see the PING commands. That is Lettuce driver behavior.

This causes a problem when any machine is down because the ping is still executed, forcing my application to wait until the ping times out.

Have you considered lowering the timeout?

In any case, these are all Lettuce driver concerns, not related to Spring Data.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2025
@mp911de mp911de added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants