mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
Set repl_down_since to zero on state change.
PR #5081 fixes an "interesting" bug about Redis Cluster failover but in general about the updating of repl_down_since, that is used in order to count the time a slave was left disconnected from its master. While the fix provided resolves the specific issue, in general the validity of repl_down_since is limited to states that are different than the state CONNECTED, and the disconnected time is set when the state is DISCONNECTED. However from CONNECTED to other states, the state machine must always go to DISCONNECTED first. So it makes sense to set the field to zero (since it is meaningless in that context) when the state is set to CONNECTED.
This commit is contained in:
parent
02e385169e
commit
677d10b2a8
@ -1087,7 +1087,6 @@ void replicationCreateMasterClient(int fd, int dbid) {
|
|||||||
if (server.master->reploff == -1)
|
if (server.master->reploff == -1)
|
||||||
server.master->flags |= CLIENT_PRE_PSYNC;
|
server.master->flags |= CLIENT_PRE_PSYNC;
|
||||||
if (dbid != -1) selectDb(server.master,dbid);
|
if (dbid != -1) selectDb(server.master,dbid);
|
||||||
server.repl_down_since = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void restartAOF() {
|
void restartAOF() {
|
||||||
@ -1280,6 +1279,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
close(server.repl_transfer_fd);
|
close(server.repl_transfer_fd);
|
||||||
replicationCreateMasterClient(server.repl_transfer_s,rsi.repl_stream_db);
|
replicationCreateMasterClient(server.repl_transfer_s,rsi.repl_stream_db);
|
||||||
server.repl_state = REPL_STATE_CONNECTED;
|
server.repl_state = REPL_STATE_CONNECTED;
|
||||||
|
server.repl_down_since = 0;
|
||||||
/* After a full resynchroniziation we use the replication ID and
|
/* After a full resynchroniziation we use the replication ID and
|
||||||
* offset of the master. The secondary ID / offset are cleared since
|
* offset of the master. The secondary ID / offset are cleared since
|
||||||
* we are starting a new history. */
|
* we are starting a new history. */
|
||||||
@ -2217,6 +2217,7 @@ void replicationResurrectCachedMaster(int newfd) {
|
|||||||
server.master->authenticated = 1;
|
server.master->authenticated = 1;
|
||||||
server.master->lastinteraction = server.unixtime;
|
server.master->lastinteraction = server.unixtime;
|
||||||
server.repl_state = REPL_STATE_CONNECTED;
|
server.repl_state = REPL_STATE_CONNECTED;
|
||||||
|
server.repl_down_since = 0;
|
||||||
|
|
||||||
/* Re-add to the list of clients. */
|
/* Re-add to the list of clients. */
|
||||||
linkClient(server.master);
|
linkClient(server.master);
|
||||||
|
Loading…
Reference in New Issue
Block a user