Skip to content

Commit

Permalink
Reset repl_down_since to zero only on state change
Browse files Browse the repository at this point in the history
We should reset repl_down_since only on state change, in the
current code, if the rdb channel in the dual channel is normal,
that is, rdb is loaded normally, but the psync channel is
abnormal, we will set repl_down_since 0 here. If the primary
is down at this time, the replica may be abnormal when calculating
data_age in cluster failover, since repl_state != REPL_STATE_CONNECTED,
this causes the replica to be unable to initiate an election due
to the old data_age.

In dualChannelSyncHandleRdbLoadCompletion, if the psync channel
is not established, the function will return. We will set repl_state
to REPL_STATE_CONNECTED and set repl_down_since to 0 in
dualChannelSyncSuccess, that is, in establishPrimaryConnection.

See also 677d10b for more details.

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Oct 11, 2024
1 parent 0142198 commit 78c84a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -2389,10 +2389,10 @@ void readSyncBulkPayload(connection *conn) {
} else {
replicationCreatePrimaryClient(server.repl_transfer_s, rsi.repl_stream_db);
server.repl_state = REPL_STATE_CONNECTED;
server.repl_down_since = 0;
/* Send the initial ACK immediately to put this replica in online state. */
replicationSendAck();
}
server.repl_down_since = 0;

/* Fire the primary link modules event. */
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP, NULL);
Expand Down

0 comments on commit 78c84a1

Please sign in to comment.