MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / processChanges

Method processChanges

src/db.cpp:2930–2981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2928}
2929
2930bool redisDbPersistentData::processChanges(bool fSnapshot)
2931{
2932 serverAssert(GlobalLocksAcquired());
2933
2934 --m_fTrackingChanges;
2935 serverAssert(m_fTrackingChanges >= 0);
2936
2937 if (m_spstorage != nullptr)
2938 {
2939 if (!m_fAllChanged && dictSize(m_dictChanged) == 0 && m_cnewKeysPending == 0)
2940 return false;
2941 m_spstorage->beginWriteBatch();
2942 serverAssert(m_pdbSnapshotStorageFlush == nullptr);
2943 if (fSnapshot && !m_fAllChanged && dictSize(m_dictChanged) > 100)
2944 {
2945 // Do a snapshot based process if possible
2946 m_pdbSnapshotStorageFlush = createSnapshot(getMvccTstamp(), true /* optional */);
2947 if (m_pdbSnapshotStorageFlush)
2948 {
2949 if (m_dictChangedStorageFlush)
2950 dictRelease(m_dictChangedStorageFlush);
2951 m_dictChangedStorageFlush = m_dictChanged;
2952 m_dictChanged = dictCreate(&dictChangeDescType, nullptr);
2953 }
2954 }
2955
2956 if (m_pdbSnapshotStorageFlush == nullptr)
2957 {
2958 if (m_fAllChanged)
2959 {
2960 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
2961 m_spstorage->clearAsync();
2962 storeDatabase();
2963 }
2964 m_fAllChanged = 0;
2965 }
2966 else
2967 {
2968 dictIterator *di = dictGetIterator(m_dictChanged);
2969 dictEntry *de;
2970 while ((de = dictNext(di)) != nullptr)
2971 {
2972 serializeAndStoreChange(m_spstorage.get(), this, (const char*)dictGetKey(de), (bool)dictGetVal(de));
2973 }
2974 dictReleaseIterator(di);
2975 }
2976 }
2977 dictEmpty(m_dictChanged, nullptr);
2978 m_cnewKeysPending = 0;
2979 }
2980 return (m_spstorage != nullptr);
2981}
2982
2983void redisDbPersistentData::processChangesAsync(std::atomic<int> &pendingJobs)
2984{

Callers 7

rdbLoadRioFunction · 0.80
readSnapshotBulkPayloadFunction · 0.80
flushStorageWeakFunction · 0.80
beforeSleepFunction · 0.80
prepareForShutdownFunction · 0.80
debugCommandFunction · 0.80
loadAppendOnlyFileFunction · 0.80

Calls 12

GlobalLocksAcquiredFunction · 0.85
getMvccTstampFunction · 0.85
dictEmptyFunction · 0.85
clearAsyncMethod · 0.80
dictReleaseFunction · 0.70
dictCreateFunction · 0.70
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70
beginWriteBatchMethod · 0.45
countMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected