mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
* refactor: remove FULL-SYNC-CUT cmd #2687
This commit is contained in:
parent
66b87e16c2
commit
dfedaf7e6e
9 changed files with 61 additions and 139 deletions
|
@ -65,39 +65,30 @@ void RestoreStreamer::Start(io::Sink* dest) {
|
|||
|
||||
JournalStreamer::Start(dest);
|
||||
|
||||
DCHECK(!snapshot_fb_.IsJoinable());
|
||||
snapshot_fb_ = fb2::Fiber("slot-snapshot", [this] {
|
||||
PrimeTable::Cursor cursor;
|
||||
uint64_t last_yield = 0;
|
||||
PrimeTable* pt = &db_slice_->databases()[0]->prime;
|
||||
PrimeTable::Cursor cursor;
|
||||
uint64_t last_yield = 0;
|
||||
PrimeTable* pt = &db_slice_->databases()[0]->prime;
|
||||
|
||||
do {
|
||||
if (fiber_cancellation_.IsCancelled())
|
||||
return;
|
||||
do {
|
||||
if (fiber_cancellation_.IsCancelled())
|
||||
return;
|
||||
|
||||
bool written = false;
|
||||
cursor = pt->Traverse(cursor, [&](PrimeTable::bucket_iterator it) {
|
||||
if (WriteBucket(it)) {
|
||||
written = true;
|
||||
}
|
||||
});
|
||||
if (written) {
|
||||
NotifyWritten(true);
|
||||
bool written = false;
|
||||
cursor = pt->Traverse(cursor, [&](PrimeTable::bucket_iterator it) {
|
||||
if (WriteBucket(it)) {
|
||||
written = true;
|
||||
}
|
||||
++last_yield;
|
||||
});
|
||||
if (written) {
|
||||
NotifyWritten(true);
|
||||
}
|
||||
++last_yield;
|
||||
|
||||
if (last_yield >= 100) {
|
||||
ThisFiber::Yield();
|
||||
last_yield = 0;
|
||||
}
|
||||
} while (cursor);
|
||||
|
||||
VLOG(2) << "FULL-SYNC-CUT for " << sync_id_ << " : " << db_slice_->shard_id();
|
||||
WriteCommand(make_pair("DFLYMIGRATE", ArgSlice{"FULL-SYNC-CUT", absl::StrCat(sync_id_),
|
||||
absl::StrCat(db_slice_->shard_id())}));
|
||||
NotifyWritten(true);
|
||||
snapshot_finished_ = true;
|
||||
});
|
||||
if (last_yield >= 100) {
|
||||
ThisFiber::Yield();
|
||||
last_yield = 0;
|
||||
}
|
||||
} while (cursor);
|
||||
}
|
||||
|
||||
void RestoreStreamer::SendFinalize() {
|
||||
|
@ -110,12 +101,10 @@ void RestoreStreamer::SendFinalize() {
|
|||
}
|
||||
|
||||
RestoreStreamer::~RestoreStreamer() {
|
||||
CHECK(!snapshot_fb_.IsJoinable());
|
||||
}
|
||||
|
||||
void RestoreStreamer::Cancel() {
|
||||
fiber_cancellation_.Cancel();
|
||||
snapshot_fb_.JoinIfNeeded();
|
||||
db_slice_->UnregisterOnChange(snapshot_version_);
|
||||
JournalStreamer::Cancel();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue