diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-20 13:31:09 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-20 13:31:09 +0200 |
| commit | 7cdafe520216f01f27094dc4a353256071510922 (patch) | |
| tree | 341e3f79cb5419c3bcb235773790d36aaff572bc /src/zenstore/include | |
| parent | Cache (rpc) activitity recording improvements (#482) (diff) | |
| download | zen-7cdafe520216f01f27094dc4a353256071510922.tar.xz zen-7cdafe520216f01f27094dc4a353256071510922.zip | |
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)
Diffstat (limited to 'src/zenstore/include')
| -rw-r--r-- | src/zenstore/include/zenstore/blockstore.h | 12 |
1 files changed, 7 insertions, 5 deletions
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<uint32_t> m_ActiveWriteBlocks; - size_t BlockCount; + std::unordered_set<uint32_t> m_BlockIndexes; }; typedef std::vector<std::pair<size_t, BlockStoreLocation>> MovedChunksArray; @@ -129,11 +129,13 @@ public: typedef std::function<void(size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size)> IterateChunksLargeSizeCallback; typedef std::function<void(const BlockStoreLocation& Location)> WriteChunkCallback; - std::unordered_map<uint32_t, uint64_t> 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<BlockStoreLocation>& KnownLocations); - void Prune(const std::vector<BlockStoreLocation>& KnownLocations); void Close(); void WriteChunk(const void* Data, uint64_t Size, uint64_t Alignment, const WriteChunkCallback& Callback); |