diff --git a/src/server.c b/src/server.c index f87193b74..bf4967c10 100644 --- a/src/server.c +++ b/src/server.c @@ -3883,6 +3883,7 @@ int processCommand(client *c) { flagTransaction(c); } clusterRedirectClient(c, n, c->slot, error_code); + c->duration = 0; c->cmd->rejected_calls++; return C_OK; } diff --git a/tests/unit/cluster/slot-migration.tcl b/tests/unit/cluster/slot-migration.tcl index 008e97e03..d4f0d43b3 100644 --- a/tests/unit/cluster/slot-migration.tcl +++ b/tests/unit/cluster/slot-migration.tcl @@ -422,3 +422,24 @@ start_cluster 3 3 {tags {external:skip cluster} overrides {cluster-allow-replica resume_process [srv -3 pid] } } + +start_cluster 2 0 {tags {external:skip cluster regression} overrides {cluster-allow-replica-migration no cluster-node-timeout 1000} } { + # Issue #563 regression test + test "Client blocked on XREADGROUP while stream's slot is migrated" { + set stream_name aga + set slot 609 + + # Start a deferring client to simulate a blocked client on XREADGROUP + R 0 XGROUP CREATE $stream_name mygroup $ MKSTREAM + set rd [valkey_deferring_client] + $rd xreadgroup GROUP mygroup consumer BLOCK 0 streams $stream_name > + wait_for_blocked_client + + # Migrate the slot to the target node + R 0 CLUSTER SETSLOT $slot MIGRATING [dict get [cluster_get_myself 1] id] + R 1 CLUSTER SETSLOT $slot IMPORTING [dict get [cluster_get_myself 0] id] + + # This line should cause the crash + R 0 MIGRATE 127.0.0.1 [lindex [R 1 CONFIG GET port] 1] $stream_name 0 5000 + } +}