aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/blockstore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-10-03 12:38:55 +0200
committerGitHub Enterprise <[email protected]>2025-10-03 12:38:55 +0200
commitb0977a20c10fa6e6f42637c709b25d22ac779d55 (patch)
tree7d5970c1206be8636e924fe85ee7ef4985f61b3d /src/zenstore/blockstore.cpp
parentremove zenutil dependency in zenremotestore (#547) (diff)
downloadzen-b0977a20c10fa6e6f42637c709b25d22ac779d55.tar.xz
zen-b0977a20c10fa6e6f42637c709b25d22ac779d55.zip
fix missing chunk (#548)
* fix race condition where BlockStoreFile::m_CachedFileSize may be reset between check and get in FileSize()
Diffstat (limited to 'src/zenstore/blockstore.cpp')
-rw-r--r--src/zenstore/blockstore.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index ec7924553..77d21834a 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -113,12 +113,14 @@ BlockStoreFile::Create(uint64_t InitialSize)
uint64_t
BlockStoreFile::FileSize() const
{
- if (m_CachedFileSize == 0)
+ uint64_t CachedSize = m_CachedFileSize;
+ if (CachedSize == 0)
{
std::error_code Ec;
uint64_t Size = m_File.FileSize(Ec);
if (Ec)
{
+ ZEN_WARN("Failed to get file size of block {}. Reason: {}", m_Path, Ec.message());
return 0;
}
uint64_t Expected = 0;
@@ -129,7 +131,7 @@ BlockStoreFile::FileSize() const
}
return Size;
}
- return m_CachedFileSize;
+ return CachedSize;
}
void
@@ -725,6 +727,14 @@ BlockStore::HasChunk(const BlockStoreLocation& Location) const
{
return true;
}
+ else
+ {
+ ZEN_WARN("BlockLocation: Block {}, Offset {}, Size {} is outside block size {}",
+ Location.BlockIndex,
+ Location.Offset,
+ Location.Size,
+ BlockSize);
+ }
}
}
return false;