From 7cdafe520216f01f27094dc4a353256071510922 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 20 Oct 2023 13:31:09 +0200 Subject: Don't prune block locations due to missing blocks a startup (#487) * Don't prune block locations due to missing blocks a startup This makes the behaviour consistent with FileCas - you can have an index that is not fully backed by data. Asking for a location that is not backed by data results in getting an empty result back Also, don't try to GC blocks that are unknown to the block store at the time of snapshot (to avoid removing data that comes in after GatherReferences in GC) --- src/zenstore/include/zenstore/blockstore.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/zenstore/include') diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h index a2dea86c1..48d33edbc 100644 --- a/src/zenstore/include/zenstore/blockstore.h +++ b/src/zenstore/include/zenstore/blockstore.h @@ -117,7 +117,7 @@ public: struct ReclaimSnapshotState { std::unordered_set m_ActiveWriteBlocks; - size_t BlockCount; + std::unordered_set m_BlockIndexes; }; typedef std::vector> MovedChunksArray; @@ -129,11 +129,13 @@ public: typedef std::function IterateChunksLargeSizeCallback; typedef std::function WriteChunkCallback; - std::unordered_map Initialize(const std::filesystem::path& BlocksBasePath, - uint64_t MaxBlockSize, - uint64_t MaxBlockCount); + void Initialize(const std::filesystem::path& BlocksBasePath, uint64_t MaxBlockSize, uint64_t MaxBlockCount); + + // Ask the store to create empty blocks for all locations that does not have a block + // This is to make sure we don't have locations that points to a block that will be written + // in the future which would result in us getting garbage data + void CreateMissingBlocks(const std::vector& KnownLocations); - void Prune(const std::vector& KnownLocations); void Close(); void WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment, const WriteChunkCallback& Callback); -- cgit v1.2.3