Merge branch 'keydbpro' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into keydbpro_collab

Former-commit-id: eca47e8d19defdc894b9dd09b2500d2e15e5fafa
This commit is contained in:
John Sully 2021-11-02 19:39:53 +00:00
commit 693e1f64a9
3 changed files with 17 additions and 9 deletions

View File

@ -2571,6 +2571,12 @@ void redisDbPersistentData::setStorageProvider(StorageCache *pstorage)
m_spstorage = std::unique_ptr<StorageCache>(pstorage); m_spstorage = std::unique_ptr<StorageCache>(pstorage);
} }
void redisDbPersistentData::endStorageProvider()
{
serverAssert(m_spstorage != nullptr);
m_spstorage.reset();
}
void clusterStorageLoadCallback(const char *rgchkey, size_t cch, void *) void clusterStorageLoadCallback(const char *rgchkey, size_t cch, void *)
{ {
slotToKeyUpdateKeyCore(rgchkey, cch, true /*add*/); slotToKeyUpdateKeyCore(rgchkey, cch, true /*add*/);
@ -2599,6 +2605,14 @@ void redisDb::storageProviderInitialize()
} }
} }
void redisDb::storageProviderDelete()
{
if (g_pserver->m_pstorageFactory != nullptr)
{
this->endStorageProvider();
}
}
bool redisDbPersistentData::insert(char *key, robj *o, bool fAssumeNew, dict_iter *piterExisting) bool redisDbPersistentData::insert(char *key, robj *o, bool fAssumeNew, dict_iter *piterExisting)
{ {
if (!fAssumeNew && (g_pserver->m_pstorageFactory != nullptr || m_pdbSnapshot != nullptr)) if (!fAssumeNew && (g_pserver->m_pstorageFactory != nullptr || m_pdbSnapshot != nullptr))

View File

@ -7080,13 +7080,6 @@ void *workerThreadMain(void *parg)
serverAssert(!GlobalLocksAcquired()); serverAssert(!GlobalLocksAcquired());
aeDeleteEventLoop(el); aeDeleteEventLoop(el);
aeAcquireLock();
for (int idb = 0; idb < cserver.dbnum; ++idb) {
if (g_pserver->rgthreadvar[iel].rgdbSnapshot[idb] != nullptr)
g_pserver->db[idb]->endSnapshot(g_pserver->rgthreadvar[iel].rgdbSnapshot[idb]);
}
aeReleaseLock();
return NULL; return NULL;
} }
@ -7508,8 +7501,7 @@ int main(int argc, char **argv) {
if (!fLockAcquired) if (!fLockAcquired)
g_fInCrash = true; // We don't actually crash right away, because we want to sync any storage providers g_fInCrash = true; // We don't actually crash right away, because we want to sync any storage providers
for (int idb = 0; idb < cserver.dbnum; ++idb) { for (int idb = 0; idb < cserver.dbnum; ++idb) {
delete g_pserver->db[idb]; g_pserver->db[idb]->storageProviderDelete();
g_pserver->db[idb] = nullptr;
} }
// If we couldn't acquire the global lock it means something wasn't shutdown and we'll probably deadlock // If we couldn't acquire the global lock it means something wasn't shutdown and we'll probably deadlock
serverAssert(fLockAcquired); serverAssert(fLockAcquired);

View File

@ -1158,6 +1158,7 @@ public:
bool FRehashing() const { return dictIsRehashing(m_pdict) || dictIsRehashing(m_pdictTombstone); } bool FRehashing() const { return dictIsRehashing(m_pdict) || dictIsRehashing(m_pdictTombstone); }
void setStorageProvider(StorageCache *pstorage); void setStorageProvider(StorageCache *pstorage);
void endStorageProvider();
void trackChanges(bool fBulk, size_t sizeHint = 0); void trackChanges(bool fBulk, size_t sizeHint = 0);
bool FTrackingChanges() const { return !!m_fTrackingChanges; } bool FTrackingChanges() const { return !!m_fTrackingChanges; }
@ -1301,6 +1302,7 @@ struct redisDb : public redisDbPersistentDataSnapshot
void initialize(int id); void initialize(int id);
void storageProviderInitialize(); void storageProviderInitialize();
void storageProviderDelete();
virtual ~redisDb(); virtual ~redisDb();
void dbOverwriteCore(redisDb::iter itr, sds keySds, robj *val, bool fUpdateMvcc, bool fRemoveExpire); void dbOverwriteCore(redisDb::iter itr, sds keySds, robj *val, bool fUpdateMvcc, bool fRemoveExpire);