aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenstore/blockstore.cpp45
2 files changed, 25 insertions, 21 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d64fd347..97b0c0502 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
- Feature: Gracefully exit if Ctrl-C is pressed
- Bugfix: Return error code on exit as set by application
- Bugfix: Fix crash at startup if dead process handles are detected in ZenServerState
+- Bugfix: Fixed assert/error when running block store GC and a block to GC does not exist
## 0.2.10
- Feature: zenserver now writes a state_marker file in the root of the data directory. Deleting this file will cause zenserver to exit. This is used to detect if user is deleting the data folder while zenserver is running
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 0593ff06b..f9e74fb0b 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -478,20 +478,7 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
}
}
- if (!OldBlockFile)
- {
- // If the block file pointed to does not exist, move them all to deleted list
- ChunkIndexArray& KeepMap = BlockKeepChunks[ChunkMapIndex];
- ZEN_ERROR("Expected to find block {} in {} - this should never happen, marking {} entries as deleted.",
- BlockIndex,
- m_BlocksBasePath,
- KeepMap.size());
-
- BlockDeleteChunks[ChunkMapIndex].insert(BlockDeleteChunks[ChunkMapIndex].end(), KeepMap.begin(), KeepMap.end());
- KeepMap.clear();
- }
-
- const ChunkIndexArray& KeepMap = BlockKeepChunks[ChunkMapIndex];
+ ChunkIndexArray& KeepMap = BlockKeepChunks[ChunkMapIndex];
if (KeepMap.empty())
{
const ChunkIndexArray& DeleteMap = BlockDeleteChunks[ChunkMapIndex];
@@ -520,8 +507,17 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
}
continue;
}
+ else if (!OldBlockFile)
+ {
+ // If the block file pointed to does not exist, move any keep chunk them to deleted list
+ ZEN_ERROR("Expected to find block {} in {} - this should never happen, marking {} entries as deleted.",
+ BlockIndex,
+ m_BlocksBasePath,
+ KeepMap.size());
- ZEN_ASSERT(OldBlockFile);
+ BlockDeleteChunks[ChunkMapIndex].insert(BlockDeleteChunks[ChunkMapIndex].end(), KeepMap.begin(), KeepMap.end());
+ KeepMap.clear();
+ }
MovedChunksArray MovedChunks;
std::vector<uint8_t> Chunk;
@@ -616,7 +612,6 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
if (NewBlockFile)
{
NewBlockFile->Flush();
- NewBlockFile = nullptr;
}
const ChunkIndexArray& DeleteMap = BlockDeleteChunks[ChunkMapIndex];
@@ -637,13 +632,21 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
ReadBlockTimeUs += ElapsedUs;
ReadBlockLongestTimeUs = std::max(ElapsedUs, ReadBlockLongestTimeUs);
});
- ZEN_DEBUG("marking cas block store file '{}' for delete, block #{}", OldBlockFile->GetPath(), BlockIndex);
- ZEN_ASSERT(m_ChunkBlocks[BlockIndex] == OldBlockFile);
- m_ChunkBlocks.erase(BlockIndex);
- m_TotalSize.fetch_sub(OldBlockFile->FileSize(), std::memory_order::relaxed);
- OldBlockFile->MarkAsDeleteOnClose();
+ if (OldBlockFile)
+ {
+ ZEN_DEBUG("marking cas block store file '{}' for delete, block #{}", OldBlockFile->GetPath(), BlockIndex);
+ ZEN_ASSERT(m_ChunkBlocks[BlockIndex] == OldBlockFile);
+ m_ChunkBlocks.erase(BlockIndex);
+ m_TotalSize.fetch_sub(OldBlockFile->FileSize(), std::memory_order::relaxed);
+ OldBlockFile->MarkAsDeleteOnClose();
+ }
}
}
+ if (NewBlockFile)
+ {
+ NewBlockFile->Flush();
+ NewBlockFile = nullptr;
+ }
}
catch (std::exception& ex)
{