Skip to content

Commit

Permalink
storage: add metrics clear to reader cache probe
Browse files Browse the repository at this point in the history
We recently ran into a double registration issue where a reader cache
was still alive even though stop() was called on it. This leads to a
double registration situation because a new reader cache will
attempt to register metrics again.

Fixes #5938
  • Loading branch information
NyaliaLui committed Aug 10, 2022
1 parent 6b9599e commit 81f9b1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/v/storage/readers_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ ss::future<> readers_cache::stop() {
_readers.clear_and_dispose([](entry* e) {
delete e; // NOLINT
});
/**
* Stop and clear metrics as well or risk a double registrion on partition
* movements. For details see https://github.com/redpanda-data/redpanda/issues/5938
*/
_probe.clear();

}

ss::future<readers_cache::range_lock_holder>
Expand Down
1 change: 1 addition & 0 deletions src/v/storage/readers_cache_probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class readers_cache_probe {
void reader_evicted() { _readers_evicted++; }
void cache_hit() { _cache_hits++; }
void cache_miss() { _cache_misses++; }
void clear() { _metrics.clear(); }

void setup_metrics(const model::ntp& ntp);

Expand Down

0 comments on commit 81f9b1d

Please sign in to comment.