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

Function flushAllDataAndResetRDB

src/db.cpp:803–826  ·  view source on GitHub ↗

Flushes the whole server data set. */

Source from the content-addressed store, hash-verified

801
802/* Flushes the whole server data set. */
803void flushAllDataAndResetRDB(int flags) {
804 g_pserver->dirty += emptyDb(-1,flags,NULL);
805 if (g_pserver->FRdbSaveInProgress()) killRDBChild();
806 if (g_pserver->saveparamslen > 0) {
807 /* Normally rdbSave() will reset dirty, but we don't want this here
808 * as otherwise FLUSHALL will not be replicated nor put into the AOF. */
809 int saved_dirty = g_pserver->dirty;
810 rdbSaveInfo rsi, *rsiptr;
811 rsiptr = rdbPopulateSaveInfo(&rsi);
812 rdbSave(nullptr, rsiptr);
813 g_pserver->dirty = saved_dirty;
814 }
815
816 /* Without that extra dirty++, when db was already empty, FLUSHALL will
817 * not be replicated nor put into the AOF. */
818 g_pserver->dirty++;
819#if defined(USE_JEMALLOC)
820 /* jemalloc 5 doesn't release pages back to the OS when there's no traffic.
821 * for large databases, flushdb blocks for long anyway, so a bit more won't
822 * harm and this way the flush and purge will be synchroneus. */
823 if (!(flags & EMPTYDB_ASYNC))
824 jemalloc_purge();
825#endif
826}
827
828/* FLUSHDB [ASYNC]
829 *

Callers 2

flushallCommandFunction · 0.85
RM_ResetDatasetFunction · 0.85

Calls 6

emptyDbFunction · 0.85
killRDBChildFunction · 0.85
rdbPopulateSaveInfoFunction · 0.85
rdbSaveFunction · 0.85
jemalloc_purgeFunction · 0.85
FRdbSaveInProgressMethod · 0.80

Tested by

no test coverage detected