diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-11 22:55:54 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-11 22:55:54 +0200 |
| commit | 432bf72c39a70d2b1eaf47c13193679c49a860ac (patch) | |
| tree | 4436dd606284b8372677b3f1f3d5d452d5b521d2 | |
| parent | 5.5.7-pre2 (diff) | |
| download | zen-432bf72c39a70d2b1eaf47c13193679c49a860ac.tar.xz zen-432bf72c39a70d2b1eaf47c13193679c49a860ac.zip | |
fix oplog state check and wiping (#154)
fix oplog state check
fix wipe of oplog storage + meta only on invalid oplog
handle vanishing oplog during gc
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenserver/projectstore/projectstore.cpp | 19 |
2 files changed, 18 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b7d66427b..959b1b5bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Improvement: zen `oplog-mirror` command now has new filter options to control which files are realized to disk: `--key` for op key, `--file` for file path matching and `--chunk` for chunk id matching - Improvement: Validate oplog log file and wipe state if it is corrupt before attempting to open - Improvement: `project-drop` command defaults to `--dry-run=true` and will only delete the target if `--dry-run=false` is added to the command line to avoid accidental delete +- Improvement: Gracefully handle oplog being deleted during early phase of GC ## 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 b0d2554d6..a34f2f4d5 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -352,7 +352,16 @@ 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); } + [[nodiscard]] static bool IsValid(const std::filesystem::path& BasePath) + { + return TCasLogFile<OplogEntry>::IsValid(GetLogPath(BasePath)); + } + void WipeState() const + { + std::error_code Ec; + std::filesystem::remove(GetLogPath(), Ec); + std::filesystem::remove(GetBlobsPath(), Ec); + } static bool Delete(const std::filesystem::path& BasePath) { return DeleteDirectories(BasePath); } @@ -950,7 +959,9 @@ ProjectStore::Oplog::Oplog(std::string_view Id, if (!m_Storage->IsValid()) { ZEN_WARN("Invalid oplog found at '{}'. Wiping state for oplog.", m_BasePath); - StoreExists = false; + m_Storage->WipeState(); + std::error_code DummyEc; + std::filesystem::remove(m_MetaPath, DummyEc); } } m_Storage->Open(/* IsCreate */ !StoreExists); @@ -5502,6 +5513,10 @@ public: Oplog = new ProjectStore::Oplog(m_OplogId, m_Project.Get(), m_Project->m_CidStore, m_OplogBasePath, std::filesystem::path{}); Oplog->Read(); } + else + { + return; + } RwLock::SharedLockScope ____(Oplog->m_OplogLock); if (Ctx.IsCancelledFlag) |