aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-15 13:34:51 +0200
committerStefan Boberg <[email protected]>2021-10-15 13:34:51 +0200
commitbb129606f34ffbf398bfab6d71a029107c135025 (patch)
tree94cf0d5b9ef9e05571b6eb35f71ade31ae27f4c3 /zenserver/cache/structuredcachestore.cpp
parenthttpasio: Implemented support for specifying accept type via url suffix (diff)
downloadzen-bb129606f34ffbf398bfab6d71a029107c135025.tar.xz
zen-bb129606f34ffbf398bfab6d71a029107c135025.zip
structured cache: fixed mistake in back-off logic
this bug would make PUTs to clean zen instances very slow
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
-rw-r--r--zenserver/cache/structuredcachestore.cpp23
1 files changed, 14 insertions, 9 deletions
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