Don't try and consolidate snapshots with a depth of 1

Former-commit-id: 26c298bd9bc4e2c6981de5c20284120ea54580c3
This commit is contained in:
John Sully 2020-08-16 00:26:05 +00:00
parent c3365964a0
commit 6ba6652fcf
2 changed files with 3 additions and 4 deletions

View File

@ -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<bool(const char*, robj_roptr o)> fn, bool fKeyOnly = false, bool fCacheOnly = false) const;

View File

@ -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<redisDbPersistentDataSnapshot*> vecT;