diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-10 17:07:06 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-10 17:07:06 +0200 |
| commit | 535ffb70546eb10635e56bf266f38599f3034279 (patch) | |
| tree | 471916bcd5a523454366eb54db330925b5fa88ba | |
| parent | Replicate releases on new release creation (#150) (diff) | |
| download | zen-535ffb70546eb10635e56bf266f38599f3034279.tar.xz zen-535ffb70546eb10635e56bf266f38599f3034279.zip | |
validate oplog before opening - if invalid, warn and wipe oplog (#153)
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenserver/projectstore/projectstore.cpp | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 21bff4613..02d0201c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## - Bugfix: Fix race condition in zenserver during batched fetch of small cache chunks (<=1024b) resulting in missing rawhash/rawsize in the response. UE-223703 - Improvement: Don't add batch overhead if we are only going to put once cache value in a request +- Improvement: Validate oplog log file and wipe state if it is corrupt before attempting to open ## 5.5.6 - Bugfix: Make sure `noexcept` functions does not leak exceptions via ASSERT statements which causes crash via abort diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp index d5570e8d4..b0d2554d6 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -351,6 +351,8 @@ struct ProjectStore::OplogStorage : public RefCounted { return std::filesystem::exists(GetLogPath(BasePath)) && std::filesystem::exists(GetBlobsPath(BasePath)); } + [[nodiscard]] bool IsValid() const { return IsValid(m_OplogStoragePath); } + [[nodiscard]] static bool IsValid(const std::filesystem::path& BasePath) { return TCasLogFile<OplogEntry>::IsValid(BasePath); } static bool Delete(const std::filesystem::path& BasePath) { return DeleteDirectories(BasePath); } @@ -941,8 +943,16 @@ ProjectStore::Oplog::Oplog(std::string_view Id, { using namespace std::literals; - m_Storage = new OplogStorage(this, m_BasePath); - const bool StoreExists = m_Storage->Exists(); + m_Storage = new OplogStorage(this, m_BasePath); + bool StoreExists = m_Storage->Exists(); + if (StoreExists) + { + if (!m_Storage->IsValid()) + { + ZEN_WARN("Invalid oplog found at '{}'. Wiping state for oplog.", m_BasePath); + StoreExists = false; + } + } m_Storage->Open(/* IsCreate */ !StoreExists); m_TempPath = m_BasePath / "temp"sv; m_MetaPath = m_BasePath / "ops.meta"sv; |