From 4b4229e3c3da530e3885ef666fea1c3200aa77de Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 23 Oct 2023 10:47:49 +0200 Subject: Remove any unreferenced blocks in block store on open (#492) * Remove any unreferenced blocks in block store on open --- src/zenserver/cache/structuredcachestore.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/zenserver/cache/structuredcachestore.cpp') diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp index 207323451..77316a5dc 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -1120,18 +1120,13 @@ TEST_CASE("z$.gc") const bool Exists = Zcs.Get(Bucket, Key, CacheValue); CHECK(!Exists); } + // GC could not remove the currently written block so size will not be zero + CHECK_NE(0, Zcs.StorageSize().DiskSize); } } { - // GC could not remove the currently written block so size will not be zero + // Unreferenced blocks will be pruned so size should now be zero ZenCacheNamespace Zcs(Gc, *JobQueue, TempDir.Path() / "cache", true); - CHECK_NE(0, Zcs.StorageSize().DiskSize); - - // GC again and now the stray write block should be removed - GcContext GcCtx(GcClock::Now() + std::chrono::minutes(2), GcClock::Now() + std::chrono::minutes(2)); - GcCtx.CollectSmallObjects(true); - Gc.CollectGarbage(GcCtx); - CHECK_EQ(0, Zcs.StorageSize().DiskSize); } } -- cgit v1.2.3