MCPcopy Create free account
hub / github.com/F-Stack/f-stack / flushAllDataAndResetRDB

Function flushAllDataAndResetRDB

app/redis-6.2.6/src/db.c:628–651  ·  view source on GitHub ↗

Flushes the whole server data set. */

Source from the content-addressed store, hash-verified

626
627/* Flushes the whole server data set. */
628void flushAllDataAndResetRDB(int flags) {
629 server.dirty += emptyDb(-1,flags,NULL);
630 if (server.child_type == CHILD_TYPE_RDB) killRDBChild();
631 if (server.saveparamslen > 0) {
632 /* Normally rdbSave() will reset dirty, but we don't want this here
633 * as otherwise FLUSHALL will not be replicated nor put into the AOF. */
634 int saved_dirty = server.dirty;
635 rdbSaveInfo rsi, *rsiptr;
636 rsiptr = rdbPopulateSaveInfo(&rsi);
637 rdbSave(server.rdb_filename,rsiptr);
638 server.dirty = saved_dirty;
639 }
640
641 /* Without that extra dirty++, when db was already empty, FLUSHALL will
642 * not be replicated nor put into the AOF. */
643 server.dirty++;
644#if defined(USE_JEMALLOC)
645 /* jemalloc 5 doesn't release pages back to the OS when there's no traffic.
646 * for large databases, flushdb blocks for long anyway, so a bit more won't
647 * harm and this way the flush and purge will be synchroneus. */
648 if (!(flags & EMPTYDB_ASYNC))
649 jemalloc_purge();
650#endif
651}
652
653/* FLUSHDB [ASYNC]
654 *

Callers 2

flushallCommandFunction · 0.85
RM_ResetDatasetFunction · 0.85

Calls 5

emptyDbFunction · 0.85
killRDBChildFunction · 0.85
rdbPopulateSaveInfoFunction · 0.85
rdbSaveFunction · 0.85
jemalloc_purgeFunction · 0.85

Tested by

no test coverage detected