From 2f07e9ad13073090f6019bce6c5633cdf960fbe6 Mon Sep 17 00:00:00 2001 From: Jacob Murphy Date: Fri, 1 Nov 2024 22:53:43 +0000 Subject: [PATCH] Fix dual channel and "replicaof no one" Signed-off-by: Jacob Murphy --- src/replication.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/replication.c b/src/replication.c index 788aea5ba1..4c0c00bdc5 100644 --- a/src/replication.c +++ b/src/replication.c @@ -3787,6 +3787,7 @@ void syncWithSource(connection *conn) { if (psync_result == PSYNC_FULLRESYNC_DUAL_CHANNEL) { /* Create RDB connection */ link->rdb_transfer_s = connCreate(connTypeOfReplication()); + connSetPrivateData(link->rdb_transfer_s, link); if (connConnect(link->rdb_transfer_s, link->host, link->port, server.bind_source_addr, dualChannelFullSyncWithSource) == C_ERR) { serverLog(LL_WARNING, "Unable to connect to Primary: %s", connGetLastError(link->transfer_s)); @@ -4038,6 +4039,8 @@ void replicationUnsetPrimary(void) { /* Clear primary_host first, since the freeClient calls * replicationHandlePrimaryDisconnection which can attempt to re-connect. */ freeReplicationLink(server.primary_replication_link); + server.primary_replication_link = NULL; + replicationDiscardCachedPrimary(); /* When a replica is turned into a primary, the current replication ID * (that was inherited from the primary at synchronization time) is