aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/cache
diff options
context:
space:
mode:
authorzousar <[email protected]>2025-12-19 00:49:38 -0700
committerzousar <[email protected]>2025-12-19 00:49:38 -0700
commit774d39bf193dd84b76437abcd41df2478e3431c0 (patch)
treeaf6550d5f2f0e292775843473260df1e2872e63a /src/zenstore/cache
parentChange default limit-overwrite behavior to true (diff)
downloadzen-774d39bf193dd84b76437abcd41df2478e3431c0.tar.xz
zen-774d39bf193dd84b76437abcd41df2478e3431c0.zip
Ensure upstream put propagation includes overwrite
When changing the default limit-overwrite behavior, a unit test surfaced a bug where an put of data with overwrite cache policy would not get propagated via zen's built-in upstream mechanism with a matching overwrite cache policy to the upstream. This change ensures that it does and leaves the unit test configured to exercise this scenario.
Diffstat (limited to 'src/zenstore/cache')
-rw-r--r--src/zenstore/cache/cacherpc.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/zenstore/cache/cacherpc.cpp b/src/zenstore/cache/cacherpc.cpp
index 6469d6c31..660c66b9a 100644
--- a/src/zenstore/cache/cacherpc.cpp
+++ b/src/zenstore/cache/cacherpc.cpp
@@ -494,7 +494,8 @@ CacheRpcHandler::PutCacheRecord(PutRequestData& Request, const CbPackage* Packag
m_UpstreamCache.EnqueueUpstream({.Type = ZenContentType::kCbPackage,
.Namespace = Request.Namespace,
.Key = Request.Key,
- .ValueContentIds = std::move(ValidAttachments)});
+ .ValueContentIds = std::move(ValidAttachments),
+ .Overwrite = Overwrite});
}
return PutResult;
}
@@ -998,6 +999,7 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
eastl::fixed_vector<size_t, 32> BatchResultIndexes;
eastl::fixed_vector<ZenCacheStore::PutResult, 32> Results;
eastl::fixed_vector<CacheKey, 32> UpstreamCacheKeys;
+ eastl::fixed_vector<bool, 32> Overwrites;
uint64_t RequestCount = RequestsArray.Num();
{
@@ -1008,6 +1010,7 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
Batch = std::make_unique<ZenCacheStore::PutBatch>(m_CacheStore, *Namespace, BatchResults);
BatchResults.reserve(RequestCount);
BatchResultIndexes.reserve(RequestCount);
+ Overwrites.reserve(RequestCount);
}
for (CbFieldView RequestField : RequestsArray)
{
@@ -1032,6 +1035,7 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
uint64_t RawSize = RequestObject["RawSize"sv].AsUInt64();
bool Valid = false;
uint64_t TransferredSize = 0;
+ bool Overwrite = false;
if (const CbAttachment* Attachment = BatchRequest.FindAttachment(RawHash))
{
@@ -1047,8 +1051,8 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
if (EnumHasAllFlags(Policy, CachePolicy::StoreLocal))
{
- bool Overwrite = !EnumHasAllFlags(Policy, CachePolicy::QueryLocal);
- IoBuffer Value = Chunk.GetCompressed().Flatten().AsIoBuffer();
+ Overwrite = !EnumHasAllFlags(Policy, CachePolicy::QueryLocal);
+ IoBuffer Value = Chunk.GetCompressed().Flatten().AsIoBuffer();
Value.SetContentType(ZenContentType::kCompressedBinary);
if (RawSize == 0)
{
@@ -1116,6 +1120,7 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
{
UpstreamCacheKeys.push_back(CacheKey::Empty);
}
+ Overwrites.push_back(Overwrite);
ZEN_DEBUG("PUTCACHEVALUES - '{}/{}/{}' {}, '{}' in {}",
*Namespace,
@@ -1150,8 +1155,10 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
{
if ((Results[Index].Status == zen::PutStatus::Success) && UpstreamCacheKeys[Index] != CacheKey::Empty)
{
- m_UpstreamCache.EnqueueUpstream(
- {.Type = ZenContentType::kCompressedBinary, .Namespace = *Namespace, .Key = UpstreamCacheKeys[Index]});
+ m_UpstreamCache.EnqueueUpstream({.Type = ZenContentType::kCompressedBinary,
+ .Namespace = *Namespace,
+ .Key = UpstreamCacheKeys[Index],
+ .Overwrite = Overwrites[Index]});
}
}
{