From a80b8c1b11538a1e5b9266c130efe1249bda87a4 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 3 Jun 2020 23:30:35 -0400 Subject: [PATCH] Fix crash where tombstone is evicted Former-commit-id: 1f6ff7cc0fc0173610d77a69076eeaf478c3b701 --- src/snapshot.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/snapshot.cpp b/src/snapshot.cpp index 78f9d19bd..7ee2b7400 100644 --- a/src/snapshot.cpp +++ b/src/snapshot.cpp @@ -283,13 +283,18 @@ void redisDbPersistentData::endSnapshot(const redisDbPersistentDataSnapshot *psn while ((de = dictNext(di)) != NULL) { dictEntry *deSnapshot = dictFind(m_spdbSnapshotHOLDER->m_pdict, dictGetKey(de)); - if (deSnapshot == nullptr) + if (deSnapshot == nullptr && m_spdbSnapshotHOLDER->m_pdbSnapshot) { - // The tombstone is for a grand child, propogate it + // The tombstone is for a grand child, propogate it (or possibly in the storage provider - but an extra tombstone won't hurt) serverAssert(m_spdbSnapshotHOLDER->m_pdbSnapshot->find_cached_threadsafe((const char*)dictGetKey(de)) != nullptr); dictAdd(m_spdbSnapshotHOLDER->m_pdictTombstone, sdsdupshared((sds)dictGetKey(de)), nullptr); continue; } + else if (deSnapshot == nullptr) + { + serverAssert(m_spdbSnapshotHOLDER->m_spstorage != nullptr); // the only case where we can have a tombstone without a snapshot child is if a storage engine is set + continue; + } const char *key = (const char*)dictGetKey(deSnapshot); dictDelete(m_spdbSnapshotHOLDER->m_pdict, key);