Set repl_down_since in freeClientAsync
Former-commit-id: fb4bd2984651837fadd1dbbbb56327e8452b4a2a
This commit is contained in:
parent
44603c8227
commit
3d424defd5
@ -158,6 +158,7 @@ client *createClient(connection *conn, int iel) {
|
||||
c->reploff_cmd = 0;
|
||||
c->repl_ack_off = 0;
|
||||
c->repl_ack_time = 0;
|
||||
c->repl_down_since = 0;
|
||||
c->slave_listening_port = 0;
|
||||
c->slave_ip[0] = '\0';
|
||||
c->slave_capa = SLAVE_CAPA_NONE;
|
||||
@ -1606,7 +1607,8 @@ void freeClientAsync(client *c) {
|
||||
AeLocker lock;
|
||||
lock.arm(c);
|
||||
if (c->flags & CLIENT_CLOSE_ASAP || c->flags & CLIENT_LUA) return; // race condition after we acquire the lock
|
||||
c->flags |= CLIENT_CLOSE_ASAP;
|
||||
c->flags |= CLIENT_CLOSE_ASAP;
|
||||
c->repl_down_since = g_pserver->unixtime;
|
||||
std::unique_lock<fastlock> ul(lockasyncfree);
|
||||
listAddNodeTail(g_pserver->clients_to_close,c);
|
||||
}
|
||||
|
@ -3213,9 +3213,14 @@ void replicationHandleMasterDisconnection(redisMaster *mi) {
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE,
|
||||
REDISMODULE_SUBEVENT_MASTER_LINK_DOWN,
|
||||
NULL);
|
||||
if (mi->master && mi->master->repl_down_since) {
|
||||
mi->repl_down_since = mi->master->repl_down_since;
|
||||
}
|
||||
else {
|
||||
mi->repl_down_since = g_pserver->unixtime;
|
||||
}
|
||||
mi->master = NULL;
|
||||
mi->repl_state = REPL_STATE_CONNECT;
|
||||
mi->repl_down_since = g_pserver->unixtime;
|
||||
/* We lost connection with our master, don't disconnect slaves yet,
|
||||
* maybe we'll be able to PSYNC with our master later. We'll disconnect
|
||||
* the slaves only if we'll have to do a full resync with our master. */
|
||||
@ -3534,6 +3539,7 @@ void replicationResurrectCachedMaster(redisMaster *mi, connection *conn) {
|
||||
mi->master->lastinteraction = g_pserver->unixtime;
|
||||
mi->repl_state = REPL_STATE_CONNECTED;
|
||||
mi->repl_down_since = 0;
|
||||
mi->master->repl_down_since = 0;
|
||||
|
||||
/* Normally changing the thread of a client is a BIG NONO,
|
||||
but this client was unlinked so its OK here */
|
||||
|
@ -6082,7 +6082,7 @@ void *timeThreadMain(void*) {
|
||||
delay.tv_nsec = 100;
|
||||
while (true) {
|
||||
updateCachedTime();
|
||||
clock_nanosleep(CLOCK_REALTIME, 0, &delay, NULL);
|
||||
clock_nanosleep(CLOCK_MONOTONIC, 0, &delay, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1509,6 +1509,7 @@ struct client {
|
||||
off_t repldboff; /* Replication DB file offset. */
|
||||
off_t repldbsize; /* Replication DB file size. */
|
||||
sds replpreamble; /* Replication DB preamble. */
|
||||
time_t repl_down_since; /* When client lost connection. */
|
||||
long long read_reploff; /* Read replication offset if this is a master. */
|
||||
long long reploff; /* Applied replication offset if this is a master. */
|
||||
long long reploff_skipped; /* Repl backlog we did not send to this client */
|
||||
|
Loading…
x
Reference in New Issue
Block a user