From 43a476a5abc021ed7785b4cc7a8b06005091a20d Mon Sep 17 00:00:00 2001 From: naglera Date: Sun, 26 May 2024 14:31:39 +0000 Subject: [PATCH] Fix client flag indexing Signed-off-by: naglera --- src/networking.c | 5 +---- src/replication.c | 7 +++++++ src/server.h | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/networking.c b/src/networking.c index e64cc81b07..45a1f4c9b5 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1707,9 +1707,6 @@ void freeClient(client *c) { moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE, NULL); - if (c->flags & CLIENT_REPL_RDB_CHANNEL) { - uint64_t id = htonu64(c->id); - raxRemove(server.slaves_waiting_psync,(unsigned char*)&id,sizeof(id),NULL); } } /* Master/slave cleanup Case 2: @@ -2740,7 +2737,7 @@ void readQueryFromClient(connection *conn) { sds info = catClientInfoString(sdsempty(), c); serverLog(LL_VERBOSE, "Client closed connection %s", info); if (c->flags & CLIENT_PROTECTED_RDB_CHANNEL) { - serverLog(LL_VERBOSE, "Postpone RDB client (%llu) free for %d seconds", (unsigned long long)c->id, server.wait_before_rdb_client_free); + serverLog(LL_VERBOSE, "Postpone RDB client id=%llu (%s) free for %d seconds", (unsigned long long)c->id, replicationGetSlaveName(c), server.wait_before_rdb_client_free); } sdsfree(info); } diff --git a/src/replication.c b/src/replication.c index 1fb944ab43..5811aeb3f3 100644 --- a/src/replication.c +++ b/src/replication.c @@ -41,6 +41,7 @@ #include #include #include +#include void replicationDiscardCachedMaster(void); void replicationResurrectCachedMaster(connection *conn); @@ -389,6 +390,12 @@ void incrementalTrimReplicationBacklog(size_t max_blocks) { /* Free replication buffer blocks that are referenced by this client. */ void freeReplicaReferencedReplBuffer(client *replica) { + if (replica->flags & CLIENT_REPL_RDB_CHANNEL) { + serverLog(LL_DEBUG, "Remove psync waiting slave %s with cid %llu from replicas rax.", + replicationGetSlaveName(replica), (long long unsigned int)replica->associated_rdb_client_id); + uint64_t id = htonu64(replica->id); + raxRemove(server.slaves_waiting_psync,(unsigned char*)&id,sizeof(id),NULL); + } if (replica->ref_repl_buf_node != NULL) { /* Decrease the start buffer node reference count. */ replBufBlock *o = listNodeValue(replica->ref_repl_buf_node); diff --git a/src/server.h b/src/server.h index ec908bd96b..9ed0b083a6 100644 --- a/src/server.h +++ b/src/server.h @@ -406,11 +406,11 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT]; #define CLIENT_REPROCESSING_COMMAND (1ULL<<50) /* The client is re-processing the command. */ #define CLIENT_PREREPL_DONE (1ULL<<51) /* Indicate that pre-replication has been done on the client */ -#define CLIENT_REPL_MAIN_CHANNEL (1ULL<<50) /* RDB Channel: track a connection +#define CLIENT_REPL_MAIN_CHANNEL (1ULL<<52) /* RDB Channel: track a connection which is used for online replication data */ -#define CLIENT_REPL_RDB_CHANNEL (1ULL<<51) /* RDB Channel: track a connection +#define CLIENT_REPL_RDB_CHANNEL (1ULL<<53) /* RDB Channel: track a connection which is used for rdb snapshot */ -#define CLIENT_PROTECTED_RDB_CHANNEL (1ULL<<52) /* Client should kept until PSYNC establishment. */ +#define CLIENT_PROTECTED_RDB_CHANNEL (1ULL<<54) /* Client should kept until PSYNC establishment. */ /* Client block type (btype field in client structure) * if CLIENT_BLOCKED flag is set. */