mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
erm: add is_leaving() to effective_replication_map
token_metadata::is_leaving() only knows whether a *host* is leaving the cluster, which is insufficient for tablets -- a tablet can be migrated away from a host (e.g. during RF reduction) without the host itself leaving. Add a pure virtual is_leaving(host, token) to effective_replication_map so callers can ask per-token questions. The vnode implementation delegates to token_metadata::is_leaving() (host-level, as before). The tablet implementation checks whether the tablet owning the token has a transition whose leaving replica matches the given host.
This commit is contained in:
@@ -345,6 +345,8 @@ public:
|
||||
virtual dht::shard_replica_set shards_ready_for_reads(const schema& s, const token& token) const {
|
||||
return {shard_for_reads(s, token)};
|
||||
}
|
||||
|
||||
virtual bool is_leaving(locator::host_id host, const dht::token& token) const = 0;
|
||||
};
|
||||
|
||||
using effective_replication_map_ptr = seastar::shared_ptr<const effective_replication_map>;
|
||||
@@ -440,6 +442,10 @@ public:
|
||||
void unregister() noexcept {
|
||||
_factory = nullptr;
|
||||
}
|
||||
|
||||
virtual bool is_leaving(locator::host_id host, const token&) const override {
|
||||
return get_token_metadata().is_leaving(host);
|
||||
}
|
||||
};
|
||||
|
||||
// Apply the replication strategy over the current configuration and the given token_metadata.
|
||||
|
||||
@@ -1445,6 +1445,22 @@ public:
|
||||
virtual dht::shard_replica_set shards_ready_for_reads(const schema& s, const token& token) const override {
|
||||
return _sharder.shards_ready_for_reads(token);
|
||||
}
|
||||
|
||||
virtual bool is_leaving(locator::host_id host, const dht::token& token) const override {
|
||||
// Check if the token belongs to the tablet which is currently being migrated away from host
|
||||
auto& tmap = get_tablet_map();
|
||||
auto tid = tmap.get_tablet_id(token);
|
||||
auto transition = tmap.get_tablet_transition_info(tid);
|
||||
if (transition) {
|
||||
auto& info = tmap.get_tablet_info(tid);
|
||||
auto leaving_opt = locator::get_leaving_replica(info, *transition);
|
||||
if (leaving_opt && leaving_opt->host == host) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void tablet_aware_replication_strategy::validate_tablet_options(const abstract_replication_strategy& ars,
|
||||
|
||||
Reference in New Issue
Block a user