mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix: Fix test_network_disconnect_during_migration
test (#4224)
There are actually a few failures fixed in this PR, only one of which is a test bug: * `db_slice_->Traverse()` can yield, causing `fiber_cancelled_`'s value to change * When a migration is cancelled, it may never finish `WaitForInflightToComplete()` because it has `in_flight_bytes_` that will never reach destination due to the cancellation * `IterateMap()` with numeric key/values overrode the key's buffer with the value's buffer Fixes #4207
This commit is contained in:
parent
dcee9a9874
commit
779bba71f9
5 changed files with 23 additions and 8 deletions
|
@ -41,7 +41,9 @@ JournalStreamer::JournalStreamer(journal::Journal* journal, Context* cntx)
|
|||
}
|
||||
|
||||
JournalStreamer::~JournalStreamer() {
|
||||
DCHECK_EQ(in_flight_bytes_, 0u);
|
||||
if (!cntx_->IsCancelled()) {
|
||||
DCHECK_EQ(in_flight_bytes_, 0u);
|
||||
}
|
||||
VLOG(1) << "~JournalStreamer";
|
||||
}
|
||||
|
||||
|
@ -79,7 +81,9 @@ void JournalStreamer::Cancel() {
|
|||
VLOG(1) << "JournalStreamer::Cancel";
|
||||
waker_.notifyAll();
|
||||
journal_->UnregisterOnChange(journal_cb_id_);
|
||||
WaitForInflightToComplete();
|
||||
if (!cntx_->IsCancelled()) {
|
||||
WaitForInflightToComplete();
|
||||
}
|
||||
}
|
||||
|
||||
size_t JournalStreamer::GetTotalBufferCapacities() const {
|
||||
|
@ -215,8 +219,15 @@ void RestoreStreamer::Run() {
|
|||
return;
|
||||
|
||||
cursor = db_slice_->Traverse(pt, cursor, [&](PrimeTable::bucket_iterator it) {
|
||||
if (fiber_cancelled_) // Could be cancelled any time as Traverse may preempt
|
||||
return;
|
||||
|
||||
db_slice_->FlushChangeToEarlierCallbacks(0 /*db_id always 0 for cluster*/,
|
||||
DbSlice::Iterator::FromPrime(it), snapshot_version_);
|
||||
|
||||
if (fiber_cancelled_) // Could have been cancelled in above call too
|
||||
return;
|
||||
|
||||
WriteBucket(it);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue