diff options
| author | zousar <[email protected]> | 2025-12-19 00:49:38 -0700 |
|---|---|---|
| committer | zousar <[email protected]> | 2025-12-19 00:49:38 -0700 |
| commit | 774d39bf193dd84b76437abcd41df2478e3431c0 (patch) | |
| tree | af6550d5f2f0e292775843473260df1e2872e63a /src/zenserver/storage/upstream/upstreamcache.cpp | |
| parent | Change default limit-overwrite behavior to true (diff) | |
| download | zen-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/zenserver/storage/upstream/upstreamcache.cpp')
| -rw-r--r-- | src/zenserver/storage/upstream/upstreamcache.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/zenserver/storage/upstream/upstreamcache.cpp b/src/zenserver/storage/upstream/upstreamcache.cpp index 938a1a011..b26c57414 100644 --- a/src/zenserver/storage/upstream/upstreamcache.cpp +++ b/src/zenserver/storage/upstream/upstreamcache.cpp @@ -554,6 +554,7 @@ namespace detail { Result = Session.PutRef(BlobStoreNamespace, CacheRecord.Key.Bucket, CacheRecord.Key.Hash, + CacheRecord.Overwrite, RecordValue, ZenContentType::kBinary); } @@ -585,6 +586,7 @@ namespace detail { Session, CacheRecord.Namespace, CacheRecord.Key, + CacheRecord.Overwrite, ReferencingObject.Save().GetBuffer().AsIoBuffer(), MaxAttempts, [&](const IoHash& ValueContentId, IoBuffer& OutBuffer, std::string& OutReason) { @@ -605,6 +607,7 @@ namespace detail { Session, CacheRecord.Namespace, CacheRecord.Key, + CacheRecord.Overwrite, RecordValue, MaxAttempts, [&](const IoHash& ValueContentId, IoBuffer& OutBuffer, std::string& OutReason) { @@ -651,6 +654,7 @@ namespace detail { JupiterSession& Session, std::string_view Namespace, const CacheKey& Key, + bool Overwrite, IoBuffer ObjectBuffer, const int32_t MaxAttempts, std::function<bool(const IoHash& ValueContentId, IoBuffer& OutBuffer, std::string& OutReason)>&& BlobFetchFn) @@ -692,7 +696,7 @@ namespace detail { PutRefResult RefResult; for (int32_t Attempt = 0; Attempt < MaxAttempts && !RefResult.Success; Attempt++) { - RefResult = Session.PutRef(BlobStoreNamespace, Key.Bucket, Key.Hash, ObjectBuffer, ZenContentType::kCbObject); + RefResult = Session.PutRef(BlobStoreNamespace, Key.Bucket, Key.Hash, Overwrite, ObjectBuffer, ZenContentType::kCbObject); } m_Status.SetFromErrorCode(RefResult.ErrorCode, RefResult.Reason); @@ -1302,6 +1306,7 @@ namespace detail { Result = Session.PutCacheRecord(CacheRecord.Namespace, CacheRecord.Key.Bucket, CacheRecord.Key.Hash, + CacheRecord.Overwrite ? CachePolicy::Store : CachePolicy::Default, PackagePayload, CacheRecord.Type); } @@ -1329,7 +1334,14 @@ namespace detail { BatchWriter.BeginObject("Params"sv); { - // DefaultPolicy unspecified and expected to be Default + if (CacheRecord.Overwrite) + { + BatchWriter << "DefaultPolicy"sv << WriteToString<128>(CachePolicy::Store).ToView(); + } + else + { + // DefaultPolicy unspecified and expected to be Default + } BatchWriter << "Namespace"sv << CacheRecord.Namespace; @@ -1376,6 +1388,7 @@ namespace detail { Result = Session.PutCacheValue(CacheRecord.Namespace, CacheRecord.Key.Bucket, CacheRecord.Key.Hash, + CacheRecord.Overwrite ? CachePolicy::Store : CachePolicy::Default, CacheRecord.ValueContentIds[Idx], Values[Idx]); } @@ -1400,6 +1413,7 @@ namespace detail { Result = Session.PutCacheRecord(CacheRecord.Namespace, CacheRecord.Key.Bucket, CacheRecord.Key.Hash, + CacheRecord.Overwrite ? CachePolicy::Store : CachePolicy::Default, RecordValue, CacheRecord.Type); } |