storage_service: get_mutable_token_metadata_ptr: always invalidate_cached_rings

We should invalidate the cached rings every time the
token metadata changes, not only on topology changes
to invalidate cached token/replication mappings
when the modified token_metadata is committed.

Currently we can do without it (apparently)
but this will become a requirement for keep
versions of the effective_replication_map
in a registry, indexed by the token_metadata ring version,
among other things.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2021-09-27 14:30:42 +03:00
parent bb0ea0b1c0
commit 08fef2a702
2 changed files with 4 additions and 2 deletions

View File

@@ -3270,8 +3270,6 @@ future<> storage_service::keyspace_changed(const sstring& ks_name) {
future<> storage_service::update_topology(inet_address endpoint) {
return container().invoke_on(0, [endpoint] (auto& ss) {
return ss.mutate_token_metadata([&ss, endpoint] (mutable_token_metadata_ptr tmptr) mutable {
// initiate the token metadata endpoints cache reset
tmptr->invalidate_cached_rings();
// re-read local rack and DC info
tmptr->update_topology(endpoint);
return make_ready_future<>();

View File

@@ -241,6 +241,10 @@ private:
future<mutable_token_metadata_ptr> get_mutable_token_metadata_ptr() noexcept {
return _shared_token_metadata.get()->clone_async().then([] (token_metadata tm) {
// bump the token_metadata ring_version
// to invalidate cached token/replication mappings
// when the modified token_metadata is committed.
tm.invalidate_cached_rings();
return make_ready_future<mutable_token_metadata_ptr>(make_token_metadata_ptr(std::move(tm)));
});
}