| 2928 | } |
| 2929 | |
| 2930 | bool 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 | |
| 2983 | void redisDbPersistentData::processChangesAsync(std::atomic<int> &pendingJobs) |
| 2984 | { |
no test coverage detected