From 795da380a2b2a3867b03c22549ed093c4b4e4ddc Mon Sep 17 00:00:00 2001 From: John Sully Date: Mon, 19 Jul 2021 18:17:54 +0000 Subject: [PATCH] Disable async rehash during load as it interferes with eviction Former-commit-id: 54b4f39e9d634bf53b04cd94433b051b14323bc6 --- src/db.cpp | 2 +- src/server.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 56556ff7f..adcf4456f 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -3020,7 +3020,7 @@ void redisDbPersistentData::removeAllCachedValues() trackChanges(false); } - if (m_pdict->pauserehash == 0) { + if (m_pdict->pauserehash == 0 && m_pdict->refcount == 1) { dict *dT = m_pdict; m_pdict = dictCreate(&dbDictType, this); dictExpand(m_pdict, dictSize(dT)/2, false); // Make room for about half so we don't excessively rehash diff --git a/src/server.cpp b/src/server.cpp index ed153d599..d32bec710 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2124,7 +2124,7 @@ void databasesCron(bool fMainThread) { ::dict *dict = g_pserver->db[rehash_db]->dictUnsafeKeyOnly(); /* Are we async rehashing? And if so is it time to re-calibrate? */ /* The recalibration limit is a prime number to ensure balancing across threads */ - if (rehashes_per_ms > 0 && async_rehashes < 131 && !cserver.active_defrag_enabled && cserver.cthreads > 1) { + if (rehashes_per_ms > 0 && async_rehashes < 131 && !cserver.active_defrag_enabled && cserver.cthreads > 1 && dictSize(dict) > 2048 && dictIsRehashing(dict) && !g_pserver->loading) { serverTL->rehashCtl = dictRehashAsyncStart(dict, rehashes_per_ms); ++async_rehashes; }