api: Drop sstable index caches on system/drop_sstable_caches

This commit is contained in:
Tomasz Grabiec
2021-07-02 01:09:16 +02:00
parent f553db69f7
commit 2c727f37fb
3 changed files with 14 additions and 0 deletions

View File

@@ -1334,6 +1334,11 @@ database::drop_caches() const {
for (auto&& e : tables) {
table& t = *e.second;
co_await t.get_row_cache().invalidate(row_cache::external_updater([] {}));
auto sstables = t.get_sstables();
for (sstables::shared_sstable sst : *sstables) {
co_await sst->drop_caches();
}
}
co_return;
}

View File

@@ -1396,6 +1396,12 @@ future<> sstable::create_data() noexcept {
});
}
future<> sstable::drop_caches() {
return _cached_index_file->evict_gently().then([this] {
return _index_cache->evict_gently();
});
}
future<> sstable::read_filter(const io_priority_class& pc) {
if (!has_component(component_type::Filter)) {
_components->filter = std::make_unique<utils::filter::always_present_filter>();

View File

@@ -815,6 +815,9 @@ public:
return _origin;
}
// Drops all evictable in-memory caches of on-disk content.
future<> drop_caches();
// Allow the test cases from sstable_test.cc to test private methods. We use
// a placeholder to avoid cluttering this class too much. The sstable_test class
// will then re-export as public every method it needs.