From 6f2d68d2c11011d541259d0037908dd76eadeb8a Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 9 Jun 2025 09:03:39 +0200 Subject: missing chunks bugfix (#424) * make sure to close log file when resetting log * drop entries that refers to missing blocks * Don't scrub keys that has been rewritten * currectly count added bytes / m_TotalSize * fix negative sleep time in BlockStoreFile::Open() * be defensive when fetching log position * append to log files *after* we updated all state successfully * explicitly close stuff in destructors with exception catching * clean up empty size block store files --- src/zenstore/include/zenstore/blockstore.h | 6 +++--- src/zenstore/include/zenstore/cache/cachedisklayer.h | 7 +++++-- 2 files changed, 8 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 8cbcad11b..fce05766f 100644 --- a/src/zenstore/include/zenstore/blockstore.h +++ b/src/zenstore/include/zenstore/blockstore.h @@ -147,10 +147,10 @@ public: typedef tsl::robin_set BlockIndexSet; - // Ask the store to create empty blocks for all locations that does not have a block // Remove any block that is not referenced - void SyncExistingBlocksOnDisk(const BlockIndexSet& KnownBlocks); - BlockEntryCountMap GetBlocksToCompact(const BlockUsageMap& BlockUsage, uint32_t BlockUsageThresholdPercent); + // Return a list of blocks that are not present + [[nodiscard]] BlockIndexSet SyncExistingBlocksOnDisk(const BlockIndexSet& KnownBlocks); + BlockEntryCountMap GetBlocksToCompact(const BlockUsageMap& BlockUsage, uint32_t BlockUsageThresholdPercent); void Close(); diff --git a/src/zenstore/include/zenstore/cache/cachedisklayer.h b/src/zenstore/include/zenstore/cache/cachedisklayer.h index b67a043df..3cd2d6423 100644 --- a/src/zenstore/include/zenstore/cache/cachedisklayer.h +++ b/src/zenstore/include/zenstore/cache/cachedisklayer.h @@ -409,19 +409,22 @@ public: void SaveSnapshot(const std::function& ClaimDiskReserveFunc = []() { return 0; }); void WriteIndexSnapshot( RwLock::ExclusiveLockScope&, + uint64_t LogPosition, bool ResetLog, const std::function& ClaimDiskReserveFunc = []() { return 0; }) { - WriteIndexSnapshotLocked(ResetLog, ClaimDiskReserveFunc); + WriteIndexSnapshotLocked(LogPosition, ResetLog, ClaimDiskReserveFunc); } void WriteIndexSnapshot( RwLock::SharedLockScope&, + uint64_t LogPosition, bool ResetLog, const std::function& ClaimDiskReserveFunc = []() { return 0; }) { - WriteIndexSnapshotLocked(ResetLog, ClaimDiskReserveFunc); + WriteIndexSnapshotLocked(LogPosition, ResetLog, ClaimDiskReserveFunc); } void WriteIndexSnapshotLocked( + uint64_t LogPosition, bool ResetLog, const std::function& ClaimDiskReserveFunc = []() { return 0; }); -- cgit v1.2.3