diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-20 11:02:02 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-20 11:02:02 +0200 |
| commit | 42cf81240256b92ef423a15add32d8b564375c7d (patch) | |
| tree | 2ec5103d1e1278b3b727955a6f92e99f8451ea1d /src | |
| parent | Change shared server config to use port 8558 (diff) | |
| download | zen-42cf81240256b92ef423a15add32d8b564375c7d.tar.xz zen-42cf81240256b92ef423a15add32d8b564375c7d.zip | |
Add --skip-delete option to gc command (#484)
- Feature: Add `--skip-delete` option to gc command
- Bugfix: Fix implementation when claiming GC reserve during GC
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/cmds/admin_cmd.cpp | 10 | ||||
| -rw-r--r-- | src/zen/cmds/admin_cmd.h | 1 | ||||
| -rw-r--r-- | src/zenserver/admin/admin.cpp | 5 | ||||
| -rw-r--r-- | src/zenserver/cache/cachedisklayer.cpp | 2 | ||||
| -rw-r--r-- | src/zenstore/compactcas.cpp | 2 | ||||
| -rw-r--r-- | src/zenstore/gc.cpp | 4 | ||||
| -rw-r--r-- | src/zenstore/include/zenstore/gc.h | 1 |
7 files changed, 23 insertions, 2 deletions
diff --git a/src/zen/cmds/admin_cmd.cpp b/src/zen/cmds/admin_cmd.cpp index 9713d8c87..27341fe58 100644 --- a/src/zen/cmds/admin_cmd.cpp +++ b/src/zen/cmds/admin_cmd.cpp @@ -76,6 +76,12 @@ GcCommand::GcCommand() "<smallobjects>"); m_Options.add_option("", "", "skipcid", "Skip collection of CAS data", cxxopts::value(m_SkipCid)->default_value("false"), "<skipcid>"); m_Options.add_option("", + "", + "skipdelete", + "Skip deletion of data (dryrun)", + cxxopts::value(m_SkipDelete)->default_value("false"), + "<skipdelete>"); + m_Options.add_option("", "m", "maxcacheduration", "Max cache lifetime (in seconds)", @@ -127,6 +133,10 @@ GcCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { Params.Add({"skipcid", "true"}); } + if (m_SkipDelete) + { + Params.Add({"skipdelete", "true"}); + } cpr::Session Session; Session.SetHeader(cpr::Header{{"Accept", "application/json"}}); diff --git a/src/zen/cmds/admin_cmd.h b/src/zen/cmds/admin_cmd.h index d1f8079b9..9d7a50e09 100644 --- a/src/zen/cmds/admin_cmd.h +++ b/src/zen/cmds/admin_cmd.h @@ -38,6 +38,7 @@ private: std::string m_HostName; bool m_SmallObjects{false}; bool m_SkipCid{false}; + bool m_SkipDelete{false}; uint64_t m_MaxCacheDuration{0}; uint64_t m_DiskSizeSoftLimit{0}; }; diff --git a/src/zenserver/admin/admin.cpp b/src/zenserver/admin/admin.cpp index 5313a7592..06a079a52 100644 --- a/src/zenserver/admin/admin.cpp +++ b/src/zenserver/admin/admin.cpp @@ -293,6 +293,11 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, GcParams.SkipCid = Param == "true"sv; } + if (auto Param = Params.GetValue("skipdelete"); Param.empty() == false) + { + GcParams.SkipDelete = Param == "true"sv; + } + const bool Started = m_GcScheduler.TriggerGc(GcParams); CbObjectWriter Response; diff --git a/src/zenserver/cache/cachedisklayer.cpp b/src/zenserver/cache/cachedisklayer.cpp index 951cc75fd..ebefa2e54 100644 --- a/src/zenserver/cache/cachedisklayer.cpp +++ b/src/zenserver/cache/cachedisklayer.cpp @@ -1865,7 +1865,7 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx) m_SlogFile.Append(LogEntries); m_SlogFile.Flush(); }, - [&]() { return GcCtx.CollectSmallObjects(); }); + [&]() { return GcCtx.ClaimGCReserve(); }); } void diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 715704c2e..a6bd71bd7 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -538,7 +538,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx) m_CasLog.Append(LogEntries); m_CasLog.Flush(); }, - [&GcCtx]() { return GcCtx.CollectSmallObjects(); }); + [&GcCtx]() { return GcCtx.ClaimGCReserve(); }); if (!DeletedChunks.empty()) { diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp index 0e4c49f65..3d8e66a8b 100644 --- a/src/zenstore/gc.cpp +++ b/src/zenstore/gc.cpp @@ -880,6 +880,10 @@ GcScheduler::SchedulerThread() { SkipCid = true; } + if (TriggerParams.SkipDelete) + { + DoDelete = false; + } } if (m_TriggerScrubParams) diff --git a/src/zenstore/include/zenstore/gc.h b/src/zenstore/include/zenstore/gc.h index aaa156ebf..1c455abe5 100644 --- a/src/zenstore/include/zenstore/gc.h +++ b/src/zenstore/include/zenstore/gc.h @@ -257,6 +257,7 @@ public: std::chrono::seconds MaxProjectStoreDuration = std::chrono::seconds::max(); uint64_t DiskSizeSoftLimit = 0; bool SkipCid = false; + bool SkipDelete = false; }; bool TriggerGc(const TriggerGcParams& Params); |