diff options
| author | Dan Engelbrecht <[email protected]> | 2023-08-01 08:51:18 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-01 08:51:18 +0200 |
| commit | d7419eb4901ec589a5dcec683b8dc052bd6d896e (patch) | |
| tree | c1b52e427c380363315c64f350ba45ab7a9693ae /src/zenserver/projectstore/jupiterremoteprojectstore.cpp | |
| parent | catch exceptions when scheduling GC and when writing GC scheduling state (#339) (diff) | |
| download | zen-d7419eb4901ec589a5dcec683b8dc052bd6d896e.tar.xz zen-d7419eb4901ec589a5dcec683b8dc052bd6d896e.zip | |
add requested item in oplog remote op (#340)
* add more context for oplog import/export errors
Diffstat (limited to 'src/zenserver/projectstore/jupiterremoteprojectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/jupiterremoteprojectstore.cpp | 105 |
1 files changed, 76 insertions, 29 deletions
diff --git a/src/zenserver/projectstore/jupiterremoteprojectstore.cpp b/src/zenserver/projectstore/jupiterremoteprojectstore.cpp index 53455beef..08c8aa0e6 100644 --- a/src/zenserver/projectstore/jupiterremoteprojectstore.cpp +++ b/src/zenserver/projectstore/jupiterremoteprojectstore.cpp @@ -46,31 +46,50 @@ public: virtual SaveResult SaveContainer(const IoBuffer& Payload) override { const int32_t MaxAttempts = 3; - PutRefResult Result; + PutRefResult PutResult; { CloudCacheSession Session(m_CloudClient.Get()); - for (int32_t Attempt = 0; Attempt < MaxAttempts && !Result.Success; Attempt++) + for (int32_t Attempt = 0; Attempt < MaxAttempts && !PutResult.Success; Attempt++) { - Result = Session.PutRef(m_Namespace, m_Bucket, m_Key, Payload, ZenContentType::kCbObject); + PutResult = Session.PutRef(m_Namespace, m_Bucket, m_Key, Payload, ZenContentType::kCbObject); } } - return SaveResult{ConvertResult(Result), {Result.Needs.begin(), Result.Needs.end()} /*, {}*/, IoHash::HashBuffer(Payload)}; + SaveResult Result{ConvertResult(PutResult), {PutResult.Needs.begin(), PutResult.Needs.end()}, IoHash::HashBuffer(Payload)}; + if (Result.ErrorCode) + { + Result.Reason = fmt::format("Failed saving oplog container to {}/{}/{}/{}. Reason: '{}'", + m_CloudClient->ServiceUrl(), + m_Namespace, + m_Bucket, + m_Key, + Result.Reason); + } + return Result; } virtual SaveAttachmentResult SaveAttachment(const CompositeBuffer& Payload, const IoHash& RawHash) override { const int32_t MaxAttempts = 3; - CloudCacheResult Result; + CloudCacheResult PutResult; { CloudCacheSession Session(m_CloudClient.Get()); - for (int32_t Attempt = 0; Attempt < MaxAttempts && !Result.Success; Attempt++) + for (int32_t Attempt = 0; Attempt < MaxAttempts && !PutResult.Success; Attempt++) { - Result = Session.PutCompressedBlob(m_Namespace, RawHash, Payload); + PutResult = Session.PutCompressedBlob(m_Namespace, RawHash, Payload); } } - return SaveAttachmentResult{ConvertResult(Result)}; + SaveAttachmentResult Result{ConvertResult(PutResult)}; + if (Result.ErrorCode) + { + Result.Reason = fmt::format("Failed saving oplog attachment to {}/{}/{}. Reason: '{}'", + m_CloudClient->ServiceUrl(), + m_Namespace, + RawHash, + Result.Reason); + } + return Result; } virtual SaveAttachmentsResult SaveAttachments(const std::vector<SharedBuffer>& Chunks) override @@ -91,60 +110,88 @@ public: virtual Result FinalizeContainer(const IoHash& RawHash) override { const int32_t MaxAttempts = 3; - CloudCacheResult Result; + CloudCacheResult FinalizeResult; { CloudCacheSession Session(m_CloudClient.Get()); - for (int32_t Attempt = 0; Attempt < MaxAttempts && !Result.Success; Attempt++) + for (int32_t Attempt = 0; Attempt < MaxAttempts && !FinalizeResult.Success; Attempt++) { - Result = Session.FinalizeRef(m_Namespace, m_Bucket, m_Key, RawHash); + FinalizeResult = Session.FinalizeRef(m_Namespace, m_Bucket, m_Key, RawHash); } } - return ConvertResult(Result); + Result Result{ConvertResult(FinalizeResult)}; + if (Result.ErrorCode) + { + Result.Reason = fmt::format("Failed finalizing oplog container to {}/{}/{}/{}. Reason: '{}'", + m_CloudClient->ServiceUrl(), + m_Namespace, + m_Bucket, + m_Key, + Result.Reason); + } + return Result; } virtual LoadContainerResult LoadContainer() override { const int32_t MaxAttempts = 3; - CloudCacheResult Result; + CloudCacheResult GetResult; { CloudCacheSession Session(m_CloudClient.Get()); - for (int32_t Attempt = 0; Attempt < MaxAttempts && !Result.Success; Attempt++) + for (int32_t Attempt = 0; Attempt < MaxAttempts && !GetResult.Success; Attempt++) { - Result = Session.GetRef(m_Namespace, m_Bucket, m_Key, ZenContentType::kCbObject); + GetResult = Session.GetRef(m_Namespace, m_Bucket, m_Key, ZenContentType::kCbObject); } } - if (Result.ErrorCode || !Result.Success) + if (GetResult.ErrorCode || !GetResult.Success) { - return LoadContainerResult{ConvertResult(Result)}; + LoadContainerResult Result{ConvertResult(GetResult)}; + Result.Reason = fmt::format("Failed fetching oplog container from {}/{}/{}/{}. Reason: '{}'", + m_CloudClient->ServiceUrl(), + m_Namespace, + m_Bucket, + m_Key, + Result.Reason); + return Result; } - CbObject ContainerObject = LoadCompactBinaryObject(Result.Response); + CbObject ContainerObject = LoadCompactBinaryObject(GetResult.Response); if (!ContainerObject) { return LoadContainerResult{ - RemoteProjectStore::Result{ - .ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError), - .ElapsedSeconds = Result.ElapsedSeconds, - .Reason = fmt::format("The ref {}/{}/{} is not formatted as a compact binary object"sv, m_Namespace, m_Bucket, m_Key)}, - std::move(ContainerObject)}; + RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError), + .ElapsedSeconds = GetResult.ElapsedSeconds, + .Reason = fmt::format("The ref {}/{}/{}/{} is not formatted as a compact binary object"sv, + m_CloudClient->ServiceUrl(), + m_Namespace, + m_Bucket, + m_Key)}, + {}}; } - - return LoadContainerResult{ConvertResult(Result), std::move(ContainerObject)}; + return LoadContainerResult{ConvertResult(GetResult), std::move(ContainerObject)}; } virtual LoadAttachmentResult LoadAttachment(const IoHash& RawHash) override { const int32_t MaxAttempts = 3; - CloudCacheResult Result; + CloudCacheResult GetResult; { CloudCacheSession Session(m_CloudClient.Get()); - for (int32_t Attempt = 0; Attempt < MaxAttempts && !Result.Success; Attempt++) + for (int32_t Attempt = 0; Attempt < MaxAttempts && !GetResult.Success; Attempt++) { - Result = Session.GetCompressedBlob(m_Namespace, RawHash); + GetResult = Session.GetCompressedBlob(m_Namespace, RawHash); } } - return LoadAttachmentResult{ConvertResult(Result), std::move(Result.Response)}; + LoadAttachmentResult Result{ConvertResult(GetResult), std::move(GetResult.Response)}; + if (GetResult.ErrorCode) + { + Result.Reason = fmt::format("Failed fetching oplog attachment from {}/{}/{}. Reason: '{}'", + m_CloudClient->ServiceUrl(), + m_Namespace, + RawHash, + Result.Reason); + } + return Result; } virtual LoadAttachmentsResult LoadAttachments(const std::vector<IoHash>& RawHashes) override |