Skip to content

Commit a0c46f4

Browse files
committed
fix assert
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
1 parent 58884f9 commit a0c46f4

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/server/db_slice.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <absl/container/flat_hash_set.h>
99

1010
#include <atomic>
11+
#include <ranges>
1112

1213
#include "common/string_or_view.h"
1314
#include "core/mi_memory_resource.h"
@@ -401,6 +402,10 @@ class DbSlice {
401402
return !change_cb_.empty();
402403
}
403404

405+
auto SnapshotVersions() const {
406+
return change_cb_ | std::views::keys;
407+
}
408+
404409
// Call registered callbacks with version less than upper_bound.
405410
void FlushChangeToEarlierCallbacks(DbIndex db_ind, Iterator it, uint64_t upper_bound);
406411

src/server/serializer_base.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ bool SerializerBase::ProcessBucketInternal(DbIndex db_index, PrimeTable::bucket_
167167
stats_.buckets_on_change += unsigned(on_update);
168168

169169
FinishBucketIteration(it.bucket_address());
170-
DCHECK_EQ(it.GetVersion(), snapshot_version_); // No parallel version changes while serializing
170+
171+
// Assert the version is equal to a snapshot version so no other modifications have happened
172+
DCHECK_GE(it.GetVersion(), snapshot_version_);
173+
auto current_snapshots = db_slice_->SnapshotVersions();
174+
DCHECK(std::ranges::find(current_snapshots, snapshot_version_) != current_snapshots.end());
171175

172176
if (EngineShard::tlocal()->tiered_storage() != nullptr)
173177
ProcessDelayedEntries(false, on_update ? it.bucket_address() : 0, base_cntx_);

0 commit comments

Comments
 (0)