mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
feat(cluster): add tx execution in cluster_shard_migration (#2385)
* feat(cluster): add tx execution in cluster_shard_migration refactor(replication): move code that is common for cluster and replica into a separate file, add full-sync-cut cmd
This commit is contained in:
parent
7debe3c685
commit
a16b940a65
17 changed files with 538 additions and 274 deletions
|
@ -49,17 +49,17 @@ void JournalStreamer::WriterFb(io::Sink* dest) {
|
|||
}
|
||||
}
|
||||
|
||||
RestoreStreamer::RestoreStreamer(DbSlice* slice, SlotSet slots, uint32_t sync_id, uint32_t flow_id,
|
||||
RestoreStreamer::RestoreStreamer(DbSlice* slice, SlotSet slots, uint32_t sync_id,
|
||||
journal::Journal* journal, Context* cntx)
|
||||
: JournalStreamer(journal, cntx),
|
||||
db_slice_(slice),
|
||||
my_slots_(std::move(slots)),
|
||||
sync_id_(sync_id),
|
||||
flow_id_(flow_id) {
|
||||
sync_id_(sync_id) {
|
||||
DCHECK(slice != nullptr);
|
||||
}
|
||||
|
||||
void RestoreStreamer::Start(io::Sink* dest) {
|
||||
VLOG(2) << "RestoreStreamer start";
|
||||
auto db_cb = absl::bind_front(&RestoreStreamer::OnDbChange, this);
|
||||
snapshot_version_ = db_slice_->RegisterOnChange(std::move(db_cb));
|
||||
|
||||
|
@ -84,8 +84,11 @@ void RestoreStreamer::Start(io::Sink* dest) {
|
|||
}
|
||||
} while (cursor);
|
||||
|
||||
WriteCommand(make_pair(
|
||||
"DFLYMIGRATE", ArgSlice{"FULL-SYNC-CUT", absl::StrCat(sync_id_), absl::StrCat(flow_id_)}));
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -96,6 +99,12 @@ void RestoreStreamer::Cancel() {
|
|||
JournalStreamer::Cancel();
|
||||
}
|
||||
|
||||
RestoreStreamer::~RestoreStreamer() {
|
||||
fiber_cancellation_.Cancel();
|
||||
snapshot_fb_.JoinIfNeeded();
|
||||
db_slice_->UnregisterOnChange(snapshot_version_);
|
||||
}
|
||||
|
||||
bool RestoreStreamer::ShouldWrite(const journal::JournalItem& item) const {
|
||||
if (!item.slot.has_value()) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue