From ac22f3c60fb046c68be6cee4cce1af1cbb63ba41 Mon Sep 17 00:00:00 2001 From: John Sully Date: Mon, 4 Oct 2021 07:35:36 +0000 Subject: [PATCH] disable key cache during load if necessary Former-commit-id: 68dcf66909e2138da4902bdec98985f4fcd737cf --- src/rdb.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rdb.cpp b/src/rdb.cpp index 44fff3244..ee66ef93e 100644 --- a/src/rdb.cpp +++ b/src/rdb.cpp @@ -2683,6 +2683,16 @@ public: ProcessWhileBlocked(); resumeExecution(); } + + if ((getMaxmemoryState(NULL,NULL,NULL,NULL) != C_OK)) { + for (int idb = 0; idb < cserver.dbnum; ++idb) { + redisDb *db = g_pserver->db[idb]; + if (db->size() > 0 && db->keycacheIsEnabled()) { + serverLog(LL_WARNING, "Key cache %d exceeds maxmemory during load, freeing - performance may be affected increase maxmemory if possible", idb); + db->disableKeyCache(); + } + } + } } }