From bb129606f34ffbf398bfab6d71a029107c135025 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Fri, 15 Oct 2021 13:34:51 +0200 Subject: structured cache: fixed mistake in back-off logic this bug would make PUTs to clean zen instances very slow --- zenserver/cache/structuredcachestore.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'zenserver/cache/structuredcachestore.cpp') diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index 9f63699e5..fcd10bdac 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -725,23 +725,28 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c DataFile.MoveTemporaryIntoPlace(FsPath, Ec); - if (Ec) + if (!Ec) { - std::error_code InnerEc; - const uint64_t ExistingFileSize = std::filesystem::file_size(FsPath, InnerEc); + break; + } - if (!InnerEc && ExistingFileSize == Value.Value.Size()) - { - // Concurrent write of same value? - return; - } + std::error_code InnerEc; + const uint64_t ExistingFileSize = std::filesystem::file_size(FsPath, InnerEc); + + if (!InnerEc && ExistingFileSize == Value.Value.Size()) + { + // Concurrent write of same value? + return; } // Semi arbitrary back-off zen::Sleep(1000 * RetryCount); } while (RetryCount--); - throw std::system_error(Ec, "Failed to finalize file '{}'"_format(WideToUtf8(DataFilePath))); + if (Ec) + { + throw std::system_error(Ec, "Failed to finalize file '{}'"_format(WideToUtf8(DataFilePath))); + } } // Update index -- cgit v1.2.3