diff --git a/locator/abstract_replication_strategy.cc b/locator/abstract_replication_strategy.cc index d54c754be7..475771a863 100644 --- a/locator/abstract_replication_strategy.cc +++ b/locator/abstract_replication_strategy.cc @@ -494,6 +494,7 @@ effective_replication_map::effective_replication_map(replication_strategy_ptr rs : _rs(std::move(rs)) , _tmptr(std::move(tmptr)) , _replication_factor(replication_factor) + , _validity_abort_source(std::make_unique()) { } vnode_effective_replication_map::factory_key vnode_effective_replication_map::make_factory_key(const replication_strategy_ptr& rs, const token_metadata_ptr& tmptr) { diff --git a/locator/abstract_replication_strategy.hh b/locator/abstract_replication_strategy.hh index 11a98ecfe9..6df2e36ff3 100644 --- a/locator/abstract_replication_strategy.hh +++ b/locator/abstract_replication_strategy.hh @@ -173,8 +173,10 @@ protected: replication_strategy_ptr _rs; token_metadata_ptr _tmptr; size_t _replication_factor; + std::unique_ptr _validity_abort_source; public: effective_replication_map(replication_strategy_ptr, token_metadata_ptr, size_t replication_factor) noexcept; + effective_replication_map(effective_replication_map&&) noexcept = default; virtual ~effective_replication_map() = default; const abstract_replication_strategy& get_replication_strategy() const noexcept { return *_rs; } @@ -183,6 +185,16 @@ public: const topology& get_topology() const noexcept { return _tmptr->get_topology(); } size_t get_replication_factor() const noexcept { return _replication_factor; } + void invalidate() const noexcept { + _validity_abort_source->request_abort(); + } + + /// Returns a reference to abort_source which is aborted when this effective replication map + /// is no longer the latest table's effective replication map. + abort_source& get_validity_abort_source() const { + return *_validity_abort_source; + } + /// Returns addresses of replicas for a given token. /// Does not include pending replicas except for a pending replica which /// has the same address as one of the old replicas. This can be the case during "nodetool replace" diff --git a/replica/table.cc b/replica/table.cc index b6056cceb9..b9c0e01011 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -1674,6 +1674,9 @@ table::table(schema_ptr schema, config config, lw_shared_ptrinvalidate(); + } _erm = std::move(erm); }