Ensure we are responsive during storagecache clears
This commit is contained in:
parent
48128dd4c7
commit
cfa9ba8eb1
@ -31,11 +31,25 @@ StorageCache::~StorageCache()
|
||||
dictRelease(m_pdict);
|
||||
}
|
||||
|
||||
void StorageCache::clear()
|
||||
void StorageCache::clear(void(callback)(void*))
|
||||
{
|
||||
std::unique_lock<fastlock> ul(m_lock);
|
||||
if (m_pdict != nullptr)
|
||||
dictEmpty(m_pdict, nullptr);
|
||||
dictEmpty(m_pdict, callback);
|
||||
m_spstorage->clear();
|
||||
m_collisionCount = 0;
|
||||
}
|
||||
|
||||
void StorageCache::clearAsync()
|
||||
{
|
||||
std::unique_lock<fastlock> ul(m_lock);
|
||||
if (m_pdict != nullptr) {
|
||||
dict *dSav = m_pdict;
|
||||
m_pdict = dictCreate(&dbStorageCacheType, nullptr);
|
||||
g_pserver->asyncworkqueue->AddWorkFunction([dSav]{
|
||||
dictEmpty(dSav, nullptr);
|
||||
});
|
||||
}
|
||||
m_spstorage->clear();
|
||||
m_collisionCount = 0;
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
return cache;
|
||||
}
|
||||
|
||||
void clear();
|
||||
void clear(void(callback)(void*));
|
||||
void clearAsync();
|
||||
void insert(sds key, const void *data, size_t cbdata, bool fOverwrite);
|
||||
void bulkInsert(char **rgkeys, size_t *rgcbkeys, char **rgvals, size_t *rgcbvals, size_t celem);
|
||||
void retrieve(sds key, IStorage::callbackSingle fn) const;
|
||||
|
@ -2706,7 +2706,7 @@ void redisDbPersistentData::clear(void(callback)(void*))
|
||||
delete m_setexpire;
|
||||
m_setexpire = new (MALLOC_LOCAL) expireset();
|
||||
if (m_spstorage != nullptr)
|
||||
m_spstorage->clear();
|
||||
m_spstorage->clear(callback);
|
||||
dictEmpty(m_pdictTombstone,callback);
|
||||
m_pdbSnapshot = nullptr;
|
||||
}
|
||||
@ -2926,7 +2926,7 @@ bool redisDbPersistentData::processChanges(bool fSnapshot)
|
||||
if (m_fAllChanged)
|
||||
{
|
||||
if (dictSize(m_pdict) > 0 || m_spstorage->count() > 0) { // in some cases we may have pre-sized the StorageCache's dict, and we don't want clear to ruin it
|
||||
m_spstorage->clear();
|
||||
m_spstorage->clearAsync();
|
||||
storeDatabase();
|
||||
}
|
||||
m_fAllChanged = 0;
|
||||
|
@ -223,7 +223,7 @@ void redisDbPersistentData::emptyDbAsync() {
|
||||
m_setexpire = new (MALLOC_LOCAL) expireset();
|
||||
m_pdict = dictCreate(&dbDictType,this);
|
||||
if (m_spstorage != nullptr)
|
||||
m_spstorage->clear();
|
||||
m_spstorage->clearAsync();
|
||||
if (m_fTrackingChanges)
|
||||
m_fAllChanged = true;
|
||||
atomicIncr(lazyfree_objects,dictSize(oldht1));
|
||||
|
Loading…
x
Reference in New Issue
Block a user