Reset repl_down_since to zero only on state change (#1149)
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 677d10b2a8ff7f13033ccfe56ffcd246dbe70fb6 for more details. Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
parent
1951aaf781
commit
710c923430
@ -2388,10 +2388,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user