fix cluster: migration crash fix (#4508)

* fix cluster: migration crash fix

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2025-01-27 10:39:11 +02:00 committed by GitHub
parent 3fdd9877f4
commit b4ef0a06e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 112 additions and 8 deletions

View file

@ -717,6 +717,7 @@ void DbSlice::FlushSlotsFb(const cluster::SlotSet& slot_ids) {
PrimeTable* table = GetTables(db_index).first;
auto iterate_bucket = [&](DbIndex db_index, PrimeTable::bucket_iterator it) {
it.AdvanceIfNotOccupied();
while (!it.is_done()) {
del_entry_cb(it);
++it;
@ -724,7 +725,7 @@ void DbSlice::FlushSlotsFb(const cluster::SlotSet& slot_ids) {
};
if (const PrimeTable::bucket_iterator* bit = req.update()) {
if (bit->GetVersion() < next_version) {
if (!bit->is_done() && bit->GetVersion() < next_version) {
iterate_bucket(db_index, *bit);
}
} else {

View file

@ -297,7 +297,7 @@ bool RestoreStreamer::ShouldWrite(SlotId slot_id) const {
bool RestoreStreamer::WriteBucket(PrimeTable::bucket_iterator it) {
bool written = false;
if (it.GetVersion() < snapshot_version_) {
if (!it.is_done() && it.GetVersion() < snapshot_version_) {
stats_.buckets_written++;
it.SetVersion(snapshot_version_);

View file

@ -390,7 +390,7 @@ void SliceSnapshot::OnDbChange(DbIndex db_index, const DbSlice::ChangeReq& req)
const PrimeTable::bucket_iterator* bit = req.update();
if (bit) {
if (bit->GetVersion() < snapshot_version_) {
if (!bit->is_done() && bit->GetVersion() < snapshot_version_) {
stats_.side_saved += SerializeBucket(db_index, *bit);
}
} else {