aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-09-04 09:14:46 -0400
committerGitHub <[email protected]>2023-09-04 15:14:46 +0200
commitf43bee9eed90ee5175f9b3e0dd2a7b7d4b3145e4 (patch)
tree02c1ed9658eadfdfd13795b932e4743b566a5941 /src/zenserver
parentadd `--write-config` to zenserver options (#382) (diff)
downloadzen-f43bee9eed90ee5175f9b3e0dd2a7b7d4b3145e4.tar.xz
zen-f43bee9eed90ee5175f9b3e0dd2a7b7d4b3145e4.zip
retry file create (#383)
* add retry logic when creating files * only write disk usage log if disk writes are allowed * changelog
Diffstat (limited to 'src/zenserver')
-rw-r--r--src/zenserver/projectstore/remoteprojectstore.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/zenserver/projectstore/remoteprojectstore.cpp b/src/zenserver/projectstore/remoteprojectstore.cpp
index 2806bc2d1..bbf3a9f32 100644
--- a/src/zenserver/projectstore/remoteprojectstore.cpp
+++ b/src/zenserver/projectstore/remoteprojectstore.cpp
@@ -277,7 +277,20 @@ BuildContainer(CidStore& ChunkStore,
if (!AttachmentBuffer)
{
BasicFile BlockFile;
- BlockFile.Open(AttachmentPath, BasicFile::Mode::kTruncateDelete);
+ uint32_t RetriesLeft = 3;
+ BlockFile.Open(AttachmentPath, BasicFile::Mode::kTruncateDelete, [&](std::error_code& Ec) {
+ if (RetriesLeft == 0)
+ {
+ return false;
+ }
+ ZEN_WARN("Failed to create temp attachment '{}', reason: '{}', retries left: {}.",
+ AttachmentPath,
+ Ec.message(),
+ RetriesLeft);
+ Sleep(100 - (3 - RetriesLeft) * 100); // Total 600 ms
+ RetriesLeft--;
+ return true;
+ });
uint64_t Offset = 0;
for (const SharedBuffer& Buffer : Compressed.GetCompressed().GetSegments())
{
@@ -637,7 +650,21 @@ SaveOplog(CidStore& ChunkStore,
try
{
BasicFile BlockFile;
- BlockFile.Open(BlockPath, BasicFile::Mode::kTruncateDelete);
+ uint32_t RetriesLeft = 3;
+ BlockFile.Open(BlockPath, BasicFile::Mode::kTruncateDelete, [&](std::error_code& Ec) {
+ if (RetriesLeft == 0)
+ {
+ return false;
+ }
+ ZEN_WARN("Failed to create temporary oplog block '{}', reason: '{}', retries left: {}.",
+ BlockPath,
+ Ec.message(),
+ RetriesLeft);
+ Sleep(100 - (3 - RetriesLeft) * 100); // Total 600 ms
+ RetriesLeft--;
+ return true;
+ });
+
uint64_t Offset = 0;
for (const SharedBuffer& Buffer : CompressedBlock.GetCompressed().GetSegments())
{