Fix race when we free an item before we finish writing to disk making it temporarily unavailable
Former-commit-id: 6139cfee295261d0210f2af6217c2a23eeaf52b8
This commit is contained in:
parent
e522540e2f
commit
9204f7b629
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user