diff options
| author | Dan Engelbrecht <[email protected]> | 2023-12-13 10:17:21 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-13 16:17:21 +0100 |
| commit | 54f9ad56c45e51ba0ce8a695ae30756d1b34d3ab (patch) | |
| tree | 7c08c31fd145e36361085b6ee076ef8593bcf276 | |
| parent | improve trace (#606) (diff) | |
| download | zen-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.md | 1 | ||||
| -rw-r--r-- | src/zenstore/blockstore.cpp | 13 |
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); |