aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-24 13:26:51 +0100
committerGitHub <[email protected]>2023-11-24 13:26:51 +0100
commit254d2f89c110fc5f14e658505559a7e7534a984d (patch)
tree511e8dcbae633ae4ccaea20f29b9b04bc41ea875 /src/zenstore/filecas.cpp
parentfix truncation of sentry hostname (diff)
downloadzen-254d2f89c110fc5f14e658505559a7e7534a984d.tar.xz
zen-254d2f89c110fc5f14e658505559a7e7534a984d.zip
Add GC Cancel/Stop (#568)
- GcScheduler will now cancel any running GC when it shuts down. - Old GC is rather limited in *when* it reacts to cancel of GC. GCv2 is more responsive.
Diffstat (limited to 'src/zenstore/filecas.cpp')
-rw-r--r--src/zenstore/filecas.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index 2623e157d..6ba282163 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -44,6 +44,15 @@ ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
+namespace {
+ template<typename T>
+ void Reset(T& V)
+ {
+ T Tmp;
+ V.swap(Tmp);
+ }
+} // namespace
+
namespace filecas::impl {
const char* IndexExtension = ".uidx";
const char* LogExtension = ".ulog";
@@ -1345,6 +1354,7 @@ public:
{
Stopwatch Timer;
const auto _ = MakeGuard([&] {
+ Reset(m_ReferencesToClean);
if (!Ctx.Settings.Verbose)
{
return;
@@ -1366,6 +1376,11 @@ public:
// Not regarded as pruned, leave it be
continue;
}
+ if (Ctx.IsCancelledFlag.load())
+ {
+ return;
+ }
+
if (Ctx.Settings.IsDeleteMode)
{
ZEN_DEBUG("GCV2: filecas [COMPACT] '{}': Deleting CAS payload file '{}'",
@@ -1418,8 +1433,7 @@ public:
ZEN_DEBUG("GCV2: filecas [COMPACT] '{}': Skipped deleting of {} eligible files", m_FileCasStrategy.m_RootDirectory, Skipped);
}
- m_ReferencesToClean.clear();
- m_ReferencesToClean.shrink_to_fit();
+ Reset(m_ReferencesToClean);
}
private:
@@ -1521,6 +1535,10 @@ FileCasStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&)
{
return {};
}
+ if (Ctx.IsCancelledFlag.load())
+ {
+ return nullptr;
+ }
CidsToCheck.reserve(m_Index.size());
for (const auto& It : m_Index)
{