diff --git a/locator/tablets.cc b/locator/tablets.cc index 6a4d8351bf..94bee2628f 100644 --- a/locator/tablets.cc +++ b/locator/tablets.cc @@ -38,6 +38,8 @@ write_replica_set_selector get_selector_for_writes(tablet_transition_stage stage return write_replica_set_selector::next; case tablet_transition_stage::cleanup: return write_replica_set_selector::next; + case tablet_transition_stage::revert_migration: + return write_replica_set_selector::previous; case tablet_transition_stage::end_migration: return write_replica_set_selector::next; } @@ -59,6 +61,8 @@ read_replica_set_selector get_selector_for_reads(tablet_transition_stage stage) return read_replica_set_selector::next; case tablet_transition_stage::cleanup: return read_replica_set_selector::next; + case tablet_transition_stage::revert_migration: + return read_replica_set_selector::previous; case tablet_transition_stage::end_migration: return read_replica_set_selector::next; } @@ -275,6 +279,7 @@ static const std::unordered_map tablet_transit {tablet_transition_stage::streaming, "streaming"}, {tablet_transition_stage::use_new, "use_new"}, {tablet_transition_stage::cleanup, "cleanup"}, + {tablet_transition_stage::revert_migration, "revert_migration"}, {tablet_transition_stage::end_migration, "end_migration"}, }; diff --git a/locator/tablets.hh b/locator/tablets.hh index 6c4aebd4a5..f2a6abdce1 100644 --- a/locator/tablets.hh +++ b/locator/tablets.hh @@ -157,6 +157,7 @@ enum class tablet_transition_stage { write_both_read_new, use_new, cleanup, + revert_migration, end_migration, }; diff --git a/service/tablet_allocator.cc b/service/tablet_allocator.cc index e613194604..300384d6a7 100644 --- a/service/tablet_allocator.cc +++ b/service/tablet_allocator.cc @@ -425,6 +425,8 @@ private: return false; case tablet_transition_stage::cleanup: return false; + case tablet_transition_stage::revert_migration: + return false; case tablet_transition_stage::end_migration: return false; } diff --git a/service/topology_coordinator.cc b/service/topology_coordinator.cc index 696194eb30..a37964b0eb 100644 --- a/service/topology_coordinator.cc +++ b/service/topology_coordinator.cc @@ -1047,6 +1047,16 @@ class topology_coordinator : public endpoint_lifecycle_subscriber { transition_to(locator::tablet_transition_stage::end_migration); } break; + case locator::tablet_transition_stage::revert_migration: + // Need a separate stage and a barrier after cleanup RPC to cut off stale RPCs. + // See do_tablet_operation() doc. + if (do_barrier()) { + _tablets.erase(gid); + updates.emplace_back(get_mutation_builder() + .del_transition(last_token) + .build()); + } + break; case locator::tablet_transition_stage::end_migration: // Need a separate stage and a barrier after cleanup RPC to cut off stale RPCs. // See do_tablet_operation() doc.