aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-09-29 13:24:44 +0200
committerGitHub Enterprise <[email protected]>2025-09-29 13:24:44 +0200
commit23edfaec29d306e055c801bb9c945c7cde5a9438 (patch)
tree2154d52bc77453e0d2bbb26c4cf45b33c7101d71
parentsplit zenserver-test monolith into multiple source files (#528) (diff)
downloadzen-23edfaec29d306e055c801bb9c945c7cde5a9438.tar.xz
zen-23edfaec29d306e055c801bb9c945c7cde5a9438.zip
more cbobject validations (#527)
- Improvement: Add additional validations when reading disk cache records to get references in GC
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp24
2 files changed, 21 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41de81d21..0a35d33d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
##
+
- Feature: `zen builds download` and `zen builds ls` now allows multiple wildcards for `--wildcard` and `--exclude-wildcard` separated by semicolons (;)
- Improvement: Gracefully handle missing chunks when exporting an oplog
+- Improvement: Add additional validations when reading disk cache records to get references in GC
- Bugfix: Fixed invalid namespace+bucket regexes in BuildStore (only fired with new MSVC compiler)
- Bugfix: `GcScheduler` could delay shutdown in some situations
- Bugfix: On exit, trace shutdown can happen before all threads completed their TLS cleanup
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index ba82dd942..de0678550 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -3450,13 +3450,27 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(const LoggerRef& Logger,
auto Log = [&Logger]() { return Logger; };
- auto GetAttachments = [&](MemoryView Data) -> bool {
- if (ValidateCompactBinary(Data, CbValidateMode::Default) == CbValidateError::None)
+ auto GetAttachments = [&](const IoHash& RawHash, MemoryView Data) -> bool {
+ if (CbValidateError Error = ValidateCompactBinary(Data, CbValidateMode::Default); Error == CbValidateError::None)
{
CbObjectView Obj(Data.GetData());
- Obj.IterateAttachments([&](CbFieldView Field) { OutReferences.emplace_back(Field.AsAttachment()); });
+ if (Obj.GetSize() == Data.GetSize())
+ {
+ Obj.IterateAttachments([&](CbFieldView Field) { OutReferences.emplace_back(Field.AsAttachment()); });
+ }
+ else
+ {
+ ZEN_WARN("Cache record {} payload is malformed. Payload size is {}, but compact binary object size is {}",
+ RawHash,
+ Data.GetSize(),
+ Obj.GetSize());
+ }
return true;
}
+ else
+ {
+ ZEN_WARN("Cache record {} payload is malformed. Reason: ", RawHash, ToString(Error));
+ }
return false;
};
@@ -3548,7 +3562,7 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(const LoggerRef& Logger,
}
auto CaptureAttachments = [&](size_t ChunkIndex, MemoryView Data) {
- if (GetAttachments(Data))
+ if (GetAttachments(InlineKeys[ChunkIndex], Data))
{
if (WriteMetaData)
{
@@ -3617,7 +3631,7 @@ ZenCacheDiskLayer::CacheBucket::GetReferences(const LoggerRef& Logger,
IoBuffer Buffer = GetStandaloneCacheValue(It.second, It.first);
if (Buffer)
{
- GetAttachments(Buffer.GetView());
+ GetAttachments(It.first, Buffer.GetView());
}
}
return true;