From f9c913a99e1f1fb98f408e3db7c0a8bd4b29dc29 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 6 Oct 2025 14:36:23 +0200 Subject: fix missing chunk in block after gc (#560) * make sure we use aligned write pos in blockstore compact when checking target block size --- src/zenstore/blockstore.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/zenstore/blockstore.cpp') 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) { -- cgit v1.2.3