We need to search snapshots before deciding to not save a key

Former-commit-id: 357b09c500eecfe61970e121644a7200ac2387b9
This commit is contained in:
John Sully 2020-06-05 00:39:58 -04:00
parent a0e502684d
commit 848cd33d51
3 changed files with 8 additions and 6 deletions

View File

@ -2442,11 +2442,11 @@ void redisDbPersistentData::processChanges()
{ {
for (auto &change : m_setchanged) for (auto &change : m_setchanged)
{ {
dictEntry *de = dictFind(m_pdict, change.strkey.get()); auto itr = find_cached_threadsafe(change.strkey.get());
if (de == nullptr) if (itr == nullptr)
continue; continue;
robj *o = (robj*)dictGetVal(de); robj *o = itr.val();
sds temp = serializeStoredObjectAndExpire(this, (const char*) dictGetKey(de), o); sds temp = serializeStoredObjectAndExpire(this, (const char*) itr.key(), o);
m_spstorage->insert(change.strkey.get(), sdslen(change.strkey.get()), temp, sdslen(temp), change.fUpdate); m_spstorage->insert(change.strkey.get(), sdslen(change.strkey.get()), temp, sdslen(temp), change.fUpdate);
sdsfree(temp); sdsfree(temp);
} }

View File

@ -1333,6 +1333,8 @@ public:
bool removeCachedValue(const char *key); bool removeCachedValue(const char *key);
void removeAllCachedValues(); void removeAllCachedValues();
dict_iter find_cached_threadsafe(const char *key) const;
protected: protected:
uint64_t m_mvccCheckpoint = 0; uint64_t m_mvccCheckpoint = 0;
@ -1397,9 +1399,9 @@ public:
using redisDbPersistentData::endSnapshot; using redisDbPersistentData::endSnapshot;
using redisDbPersistentData::endSnapshotAsync; using redisDbPersistentData::endSnapshotAsync;
using redisDbPersistentData::end; using redisDbPersistentData::end;
using redisDbPersistentData::find_cached_threadsafe;
dict_iter random_cache_threadsafe(bool fPrimaryOnly = false) const; dict_iter random_cache_threadsafe(bool fPrimaryOnly = false) const;
dict_iter find_cached_threadsafe(const char *key) const;
expireEntry *getExpire(robj_roptr key) { return getExpire(szFromObj(key)); } expireEntry *getExpire(robj_roptr key) { return getExpire(szFromObj(key)); }
expireEntry *getExpire(const char *key); expireEntry *getExpire(const char *key);

View File

@ -376,7 +376,7 @@ dict_iter redisDbPersistentDataSnapshot::random_cache_threadsafe(bool fPrimaryOn
return dict_iter(de); return dict_iter(de);
} }
dict_iter redisDbPersistentDataSnapshot::find_cached_threadsafe(const char *key) const dict_iter redisDbPersistentData::find_cached_threadsafe(const char *key) const
{ {
dictEntry *de = dictFind(m_pdict, key); dictEntry *de = dictFind(m_pdict, key);
if (de == nullptr && m_pdbSnapshot != nullptr && dictFind(m_pdictTombstone, key) == nullptr) if (de == nullptr && m_pdbSnapshot != nullptr && dictFind(m_pdictTombstone, key) == nullptr)