Enable more asserts to better validate snapshots

Former-commit-id: 01113e2eec3a0dbe0d07f98289a0050df7713047
This commit is contained in:
John Sully 2021-03-14 23:40:41 +00:00
parent 7197ba2fe5
commit d7f3f2b4e5
2 changed files with 4 additions and 3 deletions

View File

@ -2588,6 +2588,7 @@ void redisDbPersistentData::ensure(const char *sdsKey, dictEntry **pde)
{
serverAssert(sdsKey != nullptr);
serverAssert(FImplies(*pde != nullptr, dictGetVal(*pde) != nullptr)); // early versions set a NULL object, this is no longer valid
serverAssert(m_refCount == 0);
std::unique_lock<fastlock> ul(g_expireLock);
// First see if the key can be obtained from a snapshot
@ -2781,7 +2782,7 @@ redisDbPersistentData::~redisDbPersistentData()
if (m_spdbSnapshotHOLDER != nullptr)
endSnapshot(m_spdbSnapshotHOLDER.get());
//serverAssert(m_pdbSnapshot == nullptr);
serverAssert(m_pdbSnapshot == nullptr);
serverAssert(m_refCount == 0);
//serverAssert(m_pdict->iterators == 0);
serverAssert(m_pdictTombstone == nullptr || m_pdictTombstone->iterators == 0);

View File

@ -161,7 +161,7 @@ void redisDbPersistentData::recursiveFreeSnapshots(redisDbPersistentDataSnapshot
//psnapshot->m_pdict->iterators--;
psnapshot->m_spdbSnapshotHOLDER.release();
//psnapshot->m_pdbSnapshot = nullptr;
psnapshot->m_pdbSnapshot = nullptr;
g_pserver->garbageCollector.enqueue(serverTL->gcEpoch, std::unique_ptr<redisDbPersistentDataSnapshot>(psnapshot));
serverLog(LL_VERBOSE, "Garbage collected snapshot");
}
@ -427,12 +427,12 @@ void redisDbPersistentData::endSnapshot(const redisDbPersistentDataSnapshot *psn
if (m_pdbSnapshot != nullptr && m_spdbSnapshotHOLDER->m_pdbSnapshot != nullptr)
{
m_pdbSnapshot = m_spdbSnapshotHOLDER->m_pdbSnapshot;
m_spdbSnapshotHOLDER->m_pdbSnapshot = nullptr;
}
else
{
m_pdbSnapshot = nullptr;
}
m_spdbSnapshotHOLDER->m_pdbSnapshot = nullptr;
// Fixup the about to free'd snapshots iterator count so the dtor doesn't complain
if (m_refCount)