Skip to content

Commit

Permalink
Fix bug for CLUSTER SLOTS from EVAL over TLS (#1072)
Browse files Browse the repository at this point in the history
For fake clients like the ones used for Lua and modules, we don't
determine TLS in the right way, causing CLUSTER SLOTS from EVAL over TLS
to fail a debug-assert.

This error was introduced when the caching of CLUSTER SLOTS was
introduced, i.e. in 8.0.0.

Signed-off-by: Viktor Söderqvist <[email protected]>
  • Loading branch information
zuiderkwast authored Sep 25, 2024
1 parent 6b3a90e commit 99865b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ void clusterCommandSlots(client *c) {
* ... continued until done
*/
int conn_type = 0;
if (connIsTLS(c->conn)) conn_type |= CACHE_CONN_TYPE_TLS;
if (shouldReturnTlsInfo()) conn_type |= CACHE_CONN_TYPE_TLS;
if (isClientConnIpV6(c)) conn_type |= CACHE_CONN_TYPE_IPv6;
if (c->resp == 3) conn_type |= CACHE_CONN_TYPE_RESP3;

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/cluster/cluster-response-tls.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ proc get_port_from_node_info {line} {

proc cluster_response_tls {tls_cluster} {

test "CLUSTER SLOTS cached using EVAL over TLS -- tls-cluster $tls_cluster" {
set client_tcp [valkey 127.0.0.1 [srv 0 pport] 0 0]
set client_tls [valkey 127.0.0.1 [srv 0 port] 0 1]
set slots1 [$client_tls EVAL {return server.call('CLUSTER', 'SLOTS')} 0]
set slots2 [$client_tcp CLUSTER SLOTS]
# Compare the ports in the first row
assert_no_match [lindex $slots1 0 2 1] [lindex $slots2 0 2 1]
}

test "CLUSTER SLOTS with different connection type -- tls-cluster $tls_cluster" {
set slots1 [R 0 cluster slots]
set pport [srv 0 pport]
Expand Down

0 comments on commit 99865b1

Please sign in to comment.