From 57d9697e2147a23ec9e852ae1e33beca775f2680 Mon Sep 17 00:00:00 2001 From: Kseniia Sumarokova <54203879+kssenii@users.noreply.github.com> Date: Mon, 7 Aug 2023 14:27:38 +0200 Subject: [PATCH] Update FileCache.cpp --- src/Interpreters/Cache/FileCache.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Interpreters/Cache/FileCache.cpp b/src/Interpreters/Cache/FileCache.cpp index 0c4f813c8fe..3360c6e3a48 100644 --- a/src/Interpreters/Cache/FileCache.cpp +++ b/src/Interpreters/Cache/FileCache.cpp @@ -1023,7 +1023,7 @@ void FileCache::loadMetadataForKeys(const fs::path & keys_dir) if (limits_satisfied) { - KeyMetadata::iterator file_segment_metadata_it; + bool inserted = false; try { auto file_segment = std::make_shared(key, offset, size, @@ -1033,21 +1033,20 @@ void FileCache::loadMetadataForKeys(const fs::path & keys_dir) key_metadata, cache_it); - auto [_, inserted] = key_metadata->emplace(offset, std::make_shared(std::move(file_segment))); - if (!inserted) - { - cache_it->remove(lockCache()); - chassert(false); - } + inserted = key_metadata->emplace(offset, std::make_shared(std::move(file_segment))).second; + } catch (...) { tryLogCurrentException(__PRETTY_FUNCTION__); chassert(false); + } + if (!inserted) + { cache_it->remove(lockCache()); fs::remove(offset_it->path()); - continue; + chassert(false); } } else