aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-12-13 10:17:21 -0500
committerGitHub <[email protected]>2023-12-13 16:17:21 +0100
commit54f9ad56c45e51ba0ce8a695ae30756d1b34d3ab (patch)
tree7c08c31fd145e36361085b6ee076ef8593bcf276
parentimprove trace (#606) (diff)
downloadzen-54f9ad56c45e51ba0ce8a695ae30756d1b34d3ab.tar.xz
zen-54f9ad56c45e51ba0ce8a695ae30756d1b34d3ab.zip
skip invalid chunks when reclaiming space in block store (#607)
* skip invalid chunks when reclaiming space in block store
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenstore/blockstore.cpp13
2 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c42cab58..df7ee80c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
##
- Bugfix: ShutdownLogging code would throw an exception if it was called before everything had been initialised properly
- Bugfix: Reorder shutdown to avoid crash due to late async log messages (spdlog workaround)
+- Bugfix: Skip invalid chunks in block store GC when moving existing chunks
- Improvement: Adjuted and added some trace scopes
## 0.2.36
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index a11b4a323..01d7e043c 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -757,10 +757,23 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
if (OldBlockFile)
{
ZEN_TRACE_CPU("BlockStore::ReclaimSpace::MoveBlock");
+ uint64_t OldBlockSize = OldBlockFile->FileSize();
std::vector<uint8_t> Chunk;
for (const size_t& ChunkIndex : KeepMap)
{
const BlockStoreLocation ChunkLocation = ChunkLocations[ChunkIndex];
+ if (ChunkLocation.Offset + ChunkLocation.Size > OldBlockSize)
+ {
+ ZEN_WARN(
+ "ReclaimSpace skipping chunk outside of block range in '{}', Chunk start {}, Chunk size {} in Block {}, Block "
+ "size {}",
+ m_BlocksBasePath,
+ ChunkLocation.Offset,
+ ChunkLocation.Size,
+ OldBlockFile->GetPath(),
+ OldBlockSize);
+ continue;
+ }
Chunk.resize(ChunkLocation.Size);
OldBlockFile->Read(Chunk.data(), ChunkLocation.Size, ChunkLocation.Offset);