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)
{
dictEntry *de = dictFind(m_pdict, change.strkey.get());
if (de == nullptr)
auto itr = find_cached_threadsafe(change.strkey.get());
if (itr == nullptr)
continue;
robj *o = (robj*)dictGetVal(de);
sds temp = serializeStoredObjectAndExpire(this, (const char*) dictGetKey(de), o);
robj *o = itr.val();
sds temp = serializeStoredObjectAndExpire(this, (const char*) itr.key(), o);
m_spstorage->insert(change.strkey.get(), sdslen(change.strkey.get()), temp, sdslen(temp), change.fUpdate);
sdsfree(temp);
}

View File

@ -1333,6 +1333,8 @@ public:
bool removeCachedValue(const char *key);
void removeAllCachedValues();
dict_iter find_cached_threadsafe(const char *key) const;
protected:
uint64_t m_mvccCheckpoint = 0;
@ -1397,9 +1399,9 @@ public:
using redisDbPersistentData::endSnapshot;
using redisDbPersistentData::endSnapshotAsync;
using redisDbPersistentData::end;
using redisDbPersistentData::find_cached_threadsafe;
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(const char *key);

View File

@ -376,7 +376,7 @@ dict_iter redisDbPersistentDataSnapshot::random_cache_threadsafe(bool fPrimaryOn
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);
if (de == nullptr && m_pdbSnapshot != nullptr && dictFind(m_pdictTombstone, key) == nullptr)