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

Function isSafeToPerformEvictions

src/evict.cpp:574–592  ·  view source on GitHub ↗

Check if it's safe to perform evictions. * Returns 1 if evictions can be performed * Returns 0 if eviction processing should be skipped */

Source from the content-addressed store, hash-verified

572 * Returns 0 if eviction processing should be skipped
573 */
574static int isSafeToPerformEvictions(void) {
575 /* - There must be no script in timeout condition.
576 * - Nor we are loading data right now. */
577 if (g_pserver->shutdown_asap || g_pserver->lua_timedout || g_pserver->loading) return 0;
578
579 /* By default replicas should ignore maxmemory
580 * and just be masters exact copies. */
581 if (g_pserver->m_pstorageFactory == nullptr && listLength(g_pserver->masters) && g_pserver->repl_slave_ignore_maxmemory && !g_pserver->fActiveReplica) return 0;
582
583 /* If we have a lazy free obj pending, our amounts will be off, wait for it to go away */
584 if (FreeMemoryLazyFree::s_clazyFreesInProgress > 0) return 0;
585
586 /* When clients are paused the dataset should be static not just from the
587 * POV of clients not being able to write, but also from the POV of
588 * expires and evictions of keys not being performed. */
589 if (checkClientPauseTimeoutAndReturnIfPaused()) return 0;
590
591 return 1;
592}
593
594/* Algorithm for converting tenacity (0-100) to a time limit. */
595static unsigned long evictionTimeLimitUs() {

Callers 1

performEvictionsFunction · 0.85

Tested by

no test coverage detected