From 08b9f21d71dc533d39a00d6f26cb7391cbd2ee72 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 3 Mar 2021 07:06:19 +0000 Subject: [PATCH] Data loss issue due to async rehash interfering with snapshots Former-commit-id: 5245ca9a67c74b34139cafc9754543d1b8bed90a --- src/snapshot.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/snapshot.cpp b/src/snapshot.cpp index fb9b294d2..5d479fb7f 100644 --- a/src/snapshot.cpp +++ b/src/snapshot.cpp @@ -93,7 +93,17 @@ const redisDbPersistentDataSnapshot *redisDbPersistentData::createSnapshot(uint6 auto spdb = std::unique_ptr(new (MALLOC_LOCAL) redisDbPersistentDataSnapshot()); - dictRehashMilliseconds(m_pdict, 50); // Give us the best chance at a fast cleanup + // We can't have async rehash modifying these. Setting the asyncdata list to null + // will cause us to throw away the async work rather than modify the tables in flight + if (m_pdict->asyncdata != nullptr) { + m_pdict->asyncdata = nullptr; + m_pdict->rehashidx = 0; + } + if (m_pdictTombstone->asyncdata != nullptr) { + m_pdictTombstone->rehashidx = 0; + m_pdictTombstone->asyncdata = nullptr; + } + spdb->m_fAllChanged = false; spdb->m_fTrackingChanges = 0; spdb->m_pdict = m_pdict;