Fix crash on shutdown with snapshots pending

Former-commit-id: 124e79a81d6995ea7d5ba39d1830b591b705acbf
This commit is contained in:
John Sully 2020-05-24 17:11:56 -04:00
parent 7d3ed909eb
commit 69b550d91a
3 changed files with 9 additions and 3 deletions

View File

@ -2463,8 +2463,8 @@ void redisDbPersistentData::commitChanges()
redisDbPersistentData::~redisDbPersistentData()
{
if (m_pdbSnapshotASYNC)
endSnapshot(m_pdbSnapshotASYNC);
if (m_spdbSnapshotHOLDER != nullptr)
endSnapshot(m_spdbSnapshotHOLDER.get());
//serverAssert(m_pdbSnapshot == nullptr);
serverAssert(m_refCount == 0);

View File

@ -721,6 +721,6 @@ cant_free:
*
*/
int freeMemoryIfNeededAndSafe(bool fPreSnapshot) {
if (g_pserver->lua_timedout || g_pserver->loading) return C_OK;
if (g_pserver->shutdown_asap || g_pserver->lua_timedout || g_pserver->loading) return C_OK;
return freeMemoryIfNeeded(fPreSnapshot);
}

View File

@ -5926,10 +5926,16 @@ int main(int argc, char **argv) {
pthread_join(rgthread[iel], &pvRet);
/* free our databases */
bool fLockAcquired = aeTryAcquireLock(false);
g_pserver->shutdown_asap = true; // flag that we're in shutdown
if (!fLockAcquired)
g_fInCrash = true; // We don't actually crash right away, because we want to sync any storage providers
for (int idb = 0; idb < cserver.dbnum; ++idb) {
delete g_pserver->db[idb];
g_pserver->db[idb] = nullptr;
}
// If we couldn't acquire the global lock it means something wasn't shutdown and we'll probably deadlock
serverAssert(fLockAcquired);
g_pserver->garbageCollector.shutdown();
delete g_pserver->m_pstorageFactory;