diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-27 05:20:24 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-27 11:20:24 +0100 |
| commit | 6171e981b445b1850ed7c5ba7a2a5901f2227fba (patch) | |
| tree | c037df9b2cb89d1777b92d656d5f66e621af4012 /src/zenserver/projectstore/projectstore.cpp | |
| parent | Add GC Cancel/Stop (#568) (diff) | |
| download | zen-6171e981b445b1850ed7c5ba7a2a5901f2227fba.tar.xz zen-6171e981b445b1850ed7c5ba7a2a5901f2227fba.zip | |
gc stop command (#569)v0.2.36-pre2
- Feature: New endpoint `/admin/gc-stop` to cancel a running garbage collect operation
- Feature: Added `zen gc-stop` command to cancel a running garbage collect operation
- Bugfix: GCv2 - make sure to discover all projects and oplogs before checking for expired data
Diffstat (limited to 'src/zenserver/projectstore/projectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/projectstore.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp index 21aa6b44a..200aba3a9 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -3184,6 +3184,8 @@ ProjectStore::RemoveExpiredData(GcCtx& Ctx, GcStats& Stats) std::vector<Ref<Project>> ExpiredProjects; std::vector<Ref<Project>> Projects; + DiscoverProjects(); + { RwLock::SharedLockScope Lock(m_ProjectsLock); for (auto& Kv : m_Projects) @@ -3197,13 +3199,30 @@ ProjectStore::RemoveExpiredData(GcCtx& Ctx, GcStats& Stats) } } + for (const Ref<Project>& Project : Projects) + { + std::vector<std::string> OpLogs = Project->ScanForOplogs(); + for (const std::string& OpLogId : OpLogs) + { + Project->OpenOplog(OpLogId); + if (Ctx.IsCancelledFlag) + { + return nullptr; + } + } + } + size_t OplogCount = 0; size_t ExpiredOplogCount = 0; for (const Ref<Project>& Project : Projects) { + if (Ctx.IsCancelledFlag) + { + break; + } + std::vector<std::string> ExpiredOplogs; { - RwLock::ExclusiveLockScope __(m_ProjectsLock); Project->IterateOplogs( [&Ctx, &Project, &ExpiredOplogs, &OplogCount](const RwLock::SharedLockScope& Lock, ProjectStore::Oplog& Oplog) { OplogCount++; @@ -3233,7 +3252,7 @@ ProjectStore::RemoveExpiredData(GcCtx& Ctx, GcStats& Stats) Stats.CheckedCount += ProjectCount + OplogCount; - if (ExpiredProjects.empty()) + if (ExpiredProjects.empty() && ExpiredOplogCount == 0) { ZEN_DEBUG("GCV2: projectstore [REMOVE EXPIRED] '{}': no expired projects found", m_ProjectBasePath); return nullptr; |