aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/blockstore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-10-06 14:36:23 +0200
committerGitHub Enterprise <[email protected]>2025-10-06 14:36:23 +0200
commitf9c913a99e1f1fb98f408e3db7c0a8bd4b29dc29 (patch)
tree45f5d04e98589a45121d491e9ebfd027d8a7cea1 /src/zenstore/blockstore.cpp
parentchanged std::vector<bool> to std::vector<uint8_t> to avoid threading issues (... (diff)
downloadzen-f9c913a99e1f1fb98f408e3db7c0a8bd4b29dc29.tar.xz
zen-f9c913a99e1f1fb98f408e3db7c0a8bd4b29dc29.zip
fix missing chunk in block after gc (#560)
* make sure we use aligned write pos in blockstore compact when checking target block size
Diffstat (limited to 'src/zenstore/blockstore.cpp')
-rw-r--r--src/zenstore/blockstore.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 6e51247f1..0861baaf8 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -161,6 +161,7 @@ void
BlockStoreFile::Write(const void* Data, uint64_t Size, uint64_t FileOffset)
{
ZEN_TRACE_CPU("BlockStoreFile::Write");
+ ZEN_ASSERT(Size + FileOffset <= m_IoBuffer.GetSize());
m_File.Write(Data, Size, FileOffset);
m_CachedFileSize.store(0);
}
@@ -172,6 +173,7 @@ BlockStoreFile::Flush(uint64_t FinalSize)
m_File.Flush();
if (FinalSize != (uint64_t)-1)
{
+ ZEN_ASSERT(FinalSize <= m_IoBuffer.GetSize());
uint64_t ExpectedSize = 0;
while (!m_CachedFileSize.compare_exchange_weak(ExpectedSize, FinalSize))
{
@@ -1163,7 +1165,7 @@ BlockStore::CompactBlocks(const BlockStoreCompactState& CompactState,
ChunkView = MemoryView(ChunkBuffer.data(), ChunkLocation.Size);
}
- if ((WriteOffset + ChunkView.GetSize()) > m_MaxBlockSize)
+ if ((RoundUp(WriteOffset, PayloadAlignment) + ChunkView.GetSize()) > m_MaxBlockSize)
{
if (TargetFileBuffer)
{