diff --git a/src/IStorage.h b/src/IStorage.h index 3ac6d9c59..16526e80d 100644 --- a/src/IStorage.h +++ b/src/IStorage.h @@ -29,6 +29,9 @@ public: virtual void beginWriteBatch() {} // NOP virtual void endWriteBatch() {} // NOP + virtual void batch_lock() {} // NOP + virtual void batch_unlock() {} // NOP + virtual void flush() = 0; /* This is permitted to be a shallow clone */ diff --git a/src/db.cpp b/src/db.cpp index b866948fa..4c7867bd7 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -2514,12 +2514,19 @@ bool redisDbPersistentData::removeCachedValue(const char *key) { serverAssert(m_spstorage != nullptr); // First ensure its not a pending key + if (m_spstorage != nullptr) + m_spstorage->batch_lock(); + auto itr = m_setchanged.find(key); if (itr != m_setchanged.end()) return false; // can't evict // since we write ASAP the database already has a valid copy so safe to delete dictDelete(m_pdict, key); + + if (m_spstorage != nullptr) + m_spstorage->batch_unlock(); + return true; }