aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-09-11 22:55:54 +0200
committerGitHub Enterprise <[email protected]>2024-09-11 22:55:54 +0200
commit432bf72c39a70d2b1eaf47c13193679c49a860ac (patch)
tree4436dd606284b8372677b3f1f3d5d452d5b521d2 /src
parent5.5.7-pre2 (diff)
downloadzen-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
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/projectstore/projectstore.cpp19
1 files changed, 17 insertions, 2 deletions
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)