diff options
| author | Dan Engelbrecht <[email protected]> | 2025-10-17 17:02:24 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-10-17 17:02:24 +0200 |
| commit | dae0a7e1094f2ced0ce963a9a76dfb9e4ef0b5cd (patch) | |
| tree | 24430cb08abb5f9ddb70c411b0c7853d3a07c997 /src | |
| parent | add missing return statements for successful execution of zen workspace cmd (... (diff) | |
| download | zen-dae0a7e1094f2ced0ce963a9a76dfb9e4ef0b5cd.tar.xz zen-dae0a7e1094f2ced0ce963a9a76dfb9e4ef0b5cd.zip | |
fix gc state switching (#588)
* fix state issue in GC thread where shutting down gc did not always block gc from running
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenstore/gc.cpp | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp index 050ee3443..61ac2ef69 100644 --- a/src/zenstore/gc.cpp +++ b/src/zenstore/gc.cpp @@ -2469,49 +2469,39 @@ GcScheduler::SchedulerThread() WaitTime = m_Config.MonitorInterval; continue; } - } - - if (!SkipCid) - { - m_AttachmentPassIndex = NextAttachmentPassIndex; - } - bool GcSuccess = CollectGarbage(CacheExpireTime, - ProjectStoreExpireTime, - BuildStoreExpireTime, - DoDelete, - CollectSmallObjects, - SkipCid, - UseGCVersion, - CompactBlockUsageThresholdPercent, - Verbose, - SingleThreaded, - AttachmentRangeMin, - AttachmentRangeMax, - StoreCacheAttachmentMetaData, - StoreProjectAttachmentMetaData, - EnableValidation, - SilenceErrors); - if (!GcSuccess) - { - SilenceErrors = true; - ZEN_INFO("gc going into error state - gc errors will be demoted to warnings until we recover"); - } - else if (SilenceErrors) - { - SilenceErrors = false; - ZEN_INFO("gc recovered from error state - gc errors will be will be reported as errors again"); - } - - m_GcManager.SetCancelGC(false); + if (!SkipCid) + { + m_AttachmentPassIndex = NextAttachmentPassIndex; + } - uint32_t RunningState = static_cast<uint32_t>(GcSchedulerStatus::kRunning); - if (!m_Status.compare_exchange_strong(RunningState, static_cast<uint32_t>(GcSchedulerStatus::kIdle))) - { - ZEN_ASSERT(m_Status == static_cast<uint32_t>(GcSchedulerStatus::kStopped)); - break; + bool GcSuccess = CollectGarbage(CacheExpireTime, + ProjectStoreExpireTime, + BuildStoreExpireTime, + DoDelete, + CollectSmallObjects, + SkipCid, + UseGCVersion, + CompactBlockUsageThresholdPercent, + Verbose, + SingleThreaded, + AttachmentRangeMin, + AttachmentRangeMax, + StoreCacheAttachmentMetaData, + StoreProjectAttachmentMetaData, + EnableValidation, + SilenceErrors); + if (!GcSuccess) + { + SilenceErrors = true; + ZEN_INFO("gc going into error state - gc errors will be demoted to warnings until we recover"); + } + else if (SilenceErrors) + { + SilenceErrors = false; + ZEN_INFO("gc recovered from error state - gc errors will be will be reported as errors again"); + } } - WaitTime = std::chrono::seconds(0); } catch (const std::system_error& SystemError) @@ -2548,6 +2538,14 @@ GcScheduler::SchedulerThread() m_LastLightweightGcTime = m_LastGcTime; WaitTime = m_Config.MonitorInterval; } + m_GcManager.SetCancelGC(false); + + uint32_t RunningState = static_cast<uint32_t>(GcSchedulerStatus::kRunning); + if (!m_Status.compare_exchange_strong(RunningState, static_cast<uint32_t>(GcSchedulerStatus::kIdle))) + { + ZEN_ASSERT(m_Status == static_cast<uint32_t>(GcSchedulerStatus::kStopped)); + break; + } } } |