MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rdbSaveThread

Function rdbSaveThread

src/rdb.cpp:1563–1596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1561};
1562
1563void *rdbSaveThread(void *vargs)
1564{
1565 aeThreadOnline();
1566 serverAssert(!g_pserver->rdbThreadVars.fDone);
1567 rdbSaveThreadArgs *args = reinterpret_cast<rdbSaveThreadArgs*>(vargs);
1568 serverAssert(serverTL == nullptr);
1569 redisServerThreadVars vars;
1570 serverTL = &vars;
1571 vars.gcEpoch = g_pserver->garbageCollector.startEpoch();
1572
1573 int retval = rdbSave(args->rgpdb, &args->rsi);
1574 if (retval == C_OK)
1575 sendChildCowInfo(CHILD_INFO_TYPE_RDB_COW_SIZE, "RDB");
1576
1577 // If we were told to cancel the requesting thread holds the lock for us
1578 ssize_t cbStart = zmalloc_used_memory();
1579 for (int idb = 0; idb < cserver.dbnum; ++idb)
1580 g_pserver->db[idb]->endSnapshotAsync(args->rgpdb[idb]);
1581
1582 args->~rdbSaveThreadArgs();
1583 zfree(args);
1584 ssize_t cbDiff = (cbStart - (ssize_t)zmalloc_used_memory());
1585 g_pserver->garbageCollector.endEpoch(vars.gcEpoch);
1586
1587 if (cbDiff > 0)
1588 {
1589 serverLog(LL_NOTICE,
1590 "%s: %zd MB of memory used by copy-on-write",
1591 "RDB",cbDiff/(1024*1024));
1592 }
1593 aeThreadOffline();
1594 g_pserver->rdbThreadVars.fDone = true;
1595 return (retval == C_OK) ? (void*)0 : (void*)1;
1596}
1597
1598int rdbSaveBackgroundFork(rdbSaveInfo *rsi) {
1599 pid_t childpid;

Callers

nothing calls this directly

Calls 10

aeThreadOnlineFunction · 0.85
rdbSaveFunction · 0.85
sendChildCowInfoFunction · 0.85
zmalloc_used_memoryFunction · 0.85
zfreeFunction · 0.85
serverLogFunction · 0.85
aeThreadOfflineFunction · 0.85
endSnapshotAsyncMethod · 0.80
startEpochMethod · 0.45
endEpochMethod · 0.45

Tested by

no test coverage detected