fix(cluster): crash in cluster migration (#4495)

fix crash in cluster migration

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2025-01-22 14:26:53 +02:00 committed by GitHub
parent 451da72c41
commit d6adedb066
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 87 additions and 4 deletions

View file

@ -231,7 +231,7 @@ void RestoreStreamer::Run() {
ThisFiber::Yield();
last_yield = 0;
}
} while (cursor);
} while (cursor && !fiber_cancelled_);
VLOG(1) << "RestoreStreamer finished loop of " << my_slots_.ToSlotRanges().ToString()
<< ", shard " << db_slice_->shard_id() << ". Buckets looped " << stats_.buckets_loop;
@ -302,7 +302,7 @@ bool RestoreStreamer::WriteBucket(PrimeTable::bucket_iterator it) {
it.SetVersion(snapshot_version_);
string key_buffer; // we can reuse it
for (; !it.is_done(); ++it) {
for (it.AdvanceIfNotOccupied(); !it.is_done(); ++it) {
const auto& pv = it->second;
string_view key = it->first.GetSlice(&key_buffer);
if (ShouldWrite(key)) {

View file

@ -291,11 +291,10 @@ unsigned SliceSnapshot::SerializeBucket(DbIndex db_index, PrimeTable::bucket_ite
it.SetVersion(snapshot_version_);
unsigned result = 0;
while (!it.is_done()) {
for (it.AdvanceIfNotOccupied(); !it.is_done(); ++it) {
++result;
// might preempt due to big value serialization.
SerializeEntry(db_index, it->first, it->second);
++it;
}
serialize_bucket_running_ = false;
return result;