aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/cache/cachedisklayer.cpp
diff options
context:
space:
mode:
authorzousar <[email protected]>2025-09-19 23:46:52 -0600
committerzousar <[email protected]>2025-09-19 23:46:52 -0600
commit7a94b22eafdbd3f394fb9200e713cbb3b2b0cd56 (patch)
tree2ff8345484208d100000d8be805ff8f13dd2e7cc /src/zenstore/cache/cachedisklayer.cpp
parentfix quoted wildcard options (#500) (diff)
downloadzen-7a94b22eafdbd3f394fb9200e713cbb3b2b0cd56.tar.xz
zen-7a94b22eafdbd3f394fb9200e713cbb3b2b0cd56.zip
Change batch put responses for client reporting
Conflicts are now treated as successes, and we optionally return a Details array instead of an ErrorMessages array. Details are returned for all requests in a batch, or no requests in a batch depending on whether there are any details to be shared about any of the put requests. The details for a conflict include the raw hash and raw size of the item. If the item is a record, we also include the record as an object.
Diffstat (limited to 'src/zenstore/cache/cachedisklayer.cpp')
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index fd52cdab5..9a56844fe 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -1968,17 +1968,19 @@ ZenCacheDiskLayer::CacheBucket::ShouldRejectPut(const IoHash& HashKey,
IndexLock.ReleaseNow();
if (!cache::impl::UpdateValueWithRawSizeAndHash(InOutValue))
{
- OutPutResult = PutResult{zen::PutStatus::Fail, "Value provided is of bad format"};
+ CbObjectWriter DetailWriter;
+ DetailWriter.AddString("Value provided is of bad format");
+ OutPutResult = PutResult{zen::PutStatus::Fail, DetailWriter.Save()};
return true;
}
else if (MetaData.RawSize != InOutValue.RawSize || MetaData.RawHash != InOutValue.RawHash)
{
- OutPutResult = PutResult{
- zen::PutStatus::Conflict,
- fmt::format("Value exists with different size '{}' or hash '{}'", MetaData.RawSize, MetaData.RawHash)};
- return true;
+ // Deliberate fall through without return so that we load the value and include it in the result
+ }
+ else
+ {
+ return false;
}
- return false;
}
}
@@ -2008,16 +2010,27 @@ ZenCacheDiskLayer::CacheBucket::ShouldRejectPut(const IoHash& HashKey,
{
if (!cache::impl::UpdateValueWithRawSizeAndHash(InOutValue))
{
- OutPutResult = PutResult{zen::PutStatus::Fail, "Value provided is of bad format"};
+ CbObjectWriter DetailWriter;
+ DetailWriter.AddString("Value provided is of bad format");
+ OutPutResult = PutResult{zen::PutStatus::Fail, DetailWriter.Save()};
return true;
}
if (ExistingValue.RawSize != InOutValue.RawSize || ExistingValue.RawHash != InOutValue.RawHash)
{
- OutPutResult = PutResult{zen::PutStatus::Conflict,
- fmt::format("Value exists with different size '{}' or hash '{}'",
- ExistingValue.RawSize,
- ExistingValue.RawHash)};
+ CbObjectWriter DetailWriter;
+ if (Location.IsFlagSet(DiskLocation::kStructured))
+ {
+ DetailWriter.AddInteger("RawSize", ExistingValue.RawSize);
+ DetailWriter.AddHash("RawHash", ExistingValue.RawHash);
+ DetailWriter.AddObject("Object", CbObjectView(ExistingValue.Value.GetData()));
+ }
+ else
+ {
+ DetailWriter.AddInteger("RawSize", ExistingValue.RawSize);
+ DetailWriter.AddHash("RawHash", ExistingValue.RawHash);
+ }
+ OutPutResult = PutResult{zen::PutStatus::Conflict, DetailWriter.Save()};
return true;
}
}