aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/cache/cacherpc.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-12-04 16:20:58 +0100
committerGitHub Enterprise <[email protected]>2025-12-04 16:20:58 +0100
commitec69a0d3d8febf15aa5df347e514c5071c19ff71 (patch)
tree51a38b7394243281d1378f803a75a277c098edf9 /src/zenstore/cache/cacherpc.cpp
parentadd checks to protect against access violation due to failed disk read (#675) (diff)
downloadzen-ec69a0d3d8febf15aa5df347e514c5071c19ff71.tar.xz
zen-ec69a0d3d8febf15aa5df347e514c5071c19ff71.zip
batch op not in destructor (#676)
* use fixed vectors for batch requests * refactor cache batch value put/get to not execute code that can throw execeptions in destructor * extend test with multi-bucket requests
Diffstat (limited to 'src/zenstore/cache/cacherpc.cpp')
-rw-r--r--src/zenstore/cache/cacherpc.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/zenstore/cache/cacherpc.cpp b/src/zenstore/cache/cacherpc.cpp
index 9e57b41c3..6469d6c31 100644
--- a/src/zenstore/cache/cacherpc.cpp
+++ b/src/zenstore/cache/cacherpc.cpp
@@ -820,6 +820,7 @@ CacheRpcHandler::HandleRpcGetCacheRecords(const CacheRequestContext& Context, Cb
}
Request.Complete = true;
+
for (ValueRequestData& Value : Request.Values)
{
if (Value.Exists)
@@ -993,7 +994,7 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
const bool HasUpstream = m_UpstreamCache.IsActive();
CbArrayView RequestsArray = Params["Requests"sv].AsArrayView();
- std::vector<ZenCacheStore::PutResult> BatchResults;
+ ZenCacheStore::ZenCachePutResultVec_t BatchResults;
eastl::fixed_vector<size_t, 32> BatchResultIndexes;
eastl::fixed_vector<ZenCacheStore::PutResult, 32> Results;
eastl::fixed_vector<CacheKey, 32> UpstreamCacheKeys;
@@ -1124,6 +1125,11 @@ CacheRpcHandler::HandleRpcPutCacheValues(const CacheRequestContext& Context, con
Valid ? "Added"sv : "Invalid",
NiceLatencyNs(Timer.GetElapsedTimeUs() * 1000));
}
+ if (Batch)
+ {
+ Batch->Commit();
+ Batch.reset();
+ }
}
if (Results.empty())
{
@@ -1268,7 +1274,11 @@ CacheRpcHandler::HandleRpcGetCacheValues(const CacheRequestContext& Context, CbO
CacheValues.push_back({});
}
}
- Batch.reset();
+ if (Batch)
+ {
+ Batch->Commit();
+ Batch.reset();
+ }
ZEN_ASSERT(CacheValues.size() == RequestsArray.Num());
}
for (size_t RequestIndex = 0; RequestIndex < CacheValues.size(); RequestIndex++)
@@ -1818,6 +1828,11 @@ CacheRpcHandler::GetLocalCacheValues(const CacheRequestContext& Context,
}
Request->ElapsedTimeUs += Timer.GetElapsedTimeUs();
}
+ if (Batch)
+ {
+ Batch->Commit();
+ Batch.reset();
+ }
}
for (size_t RequestIndex = 0; RequestIndex < ValueRequests.size(); RequestIndex++)
{