aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenstore/blockstore.cpp4
2 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5df846db8..75c81d423 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
##
- Improvement: Oidc token executable is now launched hidden when launch from inside zenserver (oplog import/export)
- Improvement: Helper scripts `get_ue_toolchain.h` and `ue_build.sh` can now be used without passing an argument to them. If you don't specify a toolchain directory then the default of `.tmp-ue-toolchain` is used
+- Bugfix: Fixed bug in block store GC where a chunk could be lost due to writing blocks larger than max block size
## 5.7.5
- Bugfix: Parsing of `zen oplog-import` `--oidctoken-exe-path` option fixed
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)
{