From 6ba6652fcfe764341868638b9b0073500d00f69a Mon Sep 17 00:00:00 2001 From: John Sully Date: Sun, 16 Aug 2020 00:26:05 +0000 Subject: [PATCH] Don't try and consolidate snapshots with a depth of 1 Former-commit-id: 26c298bd9bc4e2c6981de5c20284120ea54580c3 --- src/server.h | 3 +-- src/snapshot.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/server.h b/src/server.h index a84368044..5c8c79a83 100644 --- a/src/server.h +++ b/src/server.h @@ -1421,13 +1421,12 @@ class redisDbPersistentDataSnapshot : protected redisDbPersistentData { friend class redisDbPersistentData; protected: - bool m_fConsolidated = false; static void gcDisposeSnapshot(redisDbPersistentDataSnapshot *psnapshot); - int snapshot_depth() const; void consolidate_children(redisDbPersistentData *pdbPrimary, bool fForce); bool freeTombstoneObjects(int depth); public: + int snapshot_depth() const; bool FWillFreeChildDebug() const { return m_spdbSnapshotHOLDER != nullptr; } bool iterate_threadsafe(std::function fn, bool fKeyOnly = false, bool fCacheOnly = false) const; diff --git a/src/snapshot.cpp b/src/snapshot.cpp index a0187f1c5..c0ca378b1 100644 --- a/src/snapshot.cpp +++ b/src/snapshot.cpp @@ -571,11 +571,12 @@ void redisDbPersistentData::consolidate_snapshot() { aeAcquireLock(); auto psnapshot = (m_pdbSnapshot != nullptr) ? m_spdbSnapshotHOLDER.get() : nullptr; - if (psnapshot == nullptr) + if (psnapshot == nullptr || psnapshot->snapshot_depth() == 0) { aeReleaseLock(); return; } + psnapshot->m_refCount++; // ensure it's not free'd aeReleaseLock(); psnapshot->consolidate_children(this, false /* fForce */); @@ -648,7 +649,6 @@ void redisDbPersistentDataSnapshot::consolidate_children(redisDbPersistentData * serverLog(LL_VERBOSE, "cleaned %d snapshots", snapshot_depth()-1); spdb->m_refCount = depth; - spdb->m_fConsolidated = true; // Drop our refs from this snapshot and its children psnapshotT = this; std::vector vecT;