From 9bb283f0505007f51cb7885b8f9c71944020813f Mon Sep 17 00:00:00 2001 From: kssenii Date: Tue, 17 Jan 2023 16:41:44 +0100 Subject: [PATCH] Fix tests --- src/Interpreters/Cache/FileCache.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Interpreters/Cache/FileCache.cpp b/src/Interpreters/Cache/FileCache.cpp index fc548b1a1e9..c38450132a8 100644 --- a/src/Interpreters/Cache/FileCache.cpp +++ b/src/Interpreters/Cache/FileCache.cpp @@ -92,12 +92,16 @@ void FileCache::initialize() { std::lock_guard lock(init_mutex); + if (is_initialized) + return; + try { loadMetadata(); } catch (...) { + tryLogCurrentException(__PRETTY_FUNCTION__); init_exception = std::current_exception(); throw; } @@ -1246,12 +1250,13 @@ std::vector FileCache::tryGetCachePaths(const Key & key) { assertInitialized(); - std::lock_guard lock(files_mutex); + auto key_transaction = createKeyTransaction(key, KeyNotFoundPolicy::RETURN_NULL); + if (!key_transaction) + return {}; - const auto & cells_by_offset = *files[key]; std::vector cache_paths; - for (const auto & [offset, cell] : cells_by_offset) + for (const auto & [offset, cell] : key_transaction->getOffsets()) { if (cell.file_segment->state() == FileSegment::State::DOWNLOADED) cache_paths.push_back(getPathInLocalCache(key, offset, cell.file_segment->getKind()));