aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/gc.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-27 05:20:24 -0500
committerGitHub <[email protected]>2023-11-27 11:20:24 +0100
commit6171e981b445b1850ed7c5ba7a2a5901f2227fba (patch)
treec037df9b2cb89d1777b92d656d5f66e621af4012 /src/zenstore/gc.cpp
parentAdd GC Cancel/Stop (#568) (diff)
downloadzen-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/zenstore/gc.cpp')
-rw-r--r--src/zenstore/gc.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp
index 2cd1f6aeb..262c94feb 100644
--- a/src/zenstore/gc.cpp
+++ b/src/zenstore/gc.cpp
@@ -1295,8 +1295,9 @@ GcScheduler::Shutdown()
bool GcIsRunning = m_Status == static_cast<uint32_t>(GcSchedulerStatus::kRunning);
if (GcIsRunning)
{
- m_GcManager.SetCancelGC(true);
+ ZEN_INFO("Requesting cancel running garbage collection");
}
+ m_GcManager.SetCancelGC(true);
m_Status = static_cast<uint32_t>(GcSchedulerStatus::kStopped);
m_GcSignal.notify_one();
@@ -1353,6 +1354,20 @@ GcScheduler::TriggerScrub(const TriggerScrubParams& Params)
return false;
}
+bool
+GcScheduler::CancelGC()
+{
+ std::unique_lock Lock(m_GcMutex);
+
+ if (static_cast<uint32_t>(GcSchedulerStatus::kRunning) == m_Status)
+ {
+ ZEN_INFO("Cancel requested for running garbage collection");
+ m_GcManager.SetCancelGC(true);
+ return true;
+ }
+ return false;
+}
+
DiskSpace
GcScheduler::CheckDiskSpace()
{