RDB thread cleanup fixes

Former-commit-id: 3e30cf6de930c40c3a1c63a761b2018836d4ae52
This commit is contained in:
John Sully 2020-02-02 23:29:20 -05:00
parent 424981309d
commit 88a148d86e

View File

@ -1464,11 +1464,20 @@ void *rdbSaveThread(void *vargs)
sendChildCOWInfo(CHILD_INFO_TYPE_RDB, "RDB"); sendChildCOWInfo(CHILD_INFO_TYPE_RDB, "RDB");
// If we were told to cancel the requesting thread holds the lock for us // If we were told to cancel the requesting thread holds the lock for us
ssize_t cbStart = zmalloc_used_memory();
for (int idb = 0; idb < cserver.dbnum; ++idb) for (int idb = 0; idb < cserver.dbnum; ++idb)
g_pserver->db[idb]->endSnapshotAsync(args->rgpdb[idb]); g_pserver->db[idb]->endSnapshotAsync(args->rgpdb[idb]);
zfree(args); zfree(args);
ssize_t cbDiff = (cbStart - (ssize_t)zmalloc_used_memory());
g_pserver->garbageCollector.endEpoch(vars.gcEpoch); g_pserver->garbageCollector.endEpoch(vars.gcEpoch);
if (cbDiff > 0)
{
serverLog(LL_NOTICE,
"%s: %zd MB of memory used by copy-on-write",
"RDB",cbDiff/(1024*1024));
}
return (retval == C_OK) ? (void*)0 : (void*)1; return (retval == C_OK) ? (void*)0 : (void*)1;
} }
@ -2658,6 +2667,11 @@ void *rdbSaveToSlavesSocketsThread(void *vargs)
int retval; int retval;
rio rdb; rio rdb;
serverAssert(serverTL == nullptr);
redisServerThreadVars vars;
serverTL = &vars;
vars.gcEpoch = g_pserver->garbageCollector.startEpoch();
rioInitWithFd(&rdb,g_pserver->rdb_pipe_write); rioInitWithFd(&rdb,g_pserver->rdb_pipe_write);
retval = rdbSaveRioWithEOFMark(&rdb,args->rgpdb,NULL,&args->rsi); retval = rdbSaveRioWithEOFMark(&rdb,args->rgpdb,NULL,&args->rsi);
@ -2676,6 +2690,8 @@ void *rdbSaveToSlavesSocketsThread(void *vargs)
g_pserver->db[idb]->endSnapshotAsync(args->rgpdb[idb]); g_pserver->db[idb]->endSnapshotAsync(args->rgpdb[idb]);
zfree(args); zfree(args);
g_pserver->garbageCollector.endEpoch(vars.gcEpoch);
return (retval == C_OK) ? (void*)0 : (void*)1; return (retval == C_OK) ? (void*)0 : (void*)1;
} }