fix: retry cache lookup after busy operation

This commit is contained in:
torlando-agent[bot]
2026-08-17 06:03:38 +00:00
parent 16af3b53af
commit 3658c54cc7
3 changed files with 26 additions and 3 deletions
+17 -3
View File
@@ -11,6 +11,7 @@ CacheFlowState NomadNetCacheFlow::begin(const CacheKey& key, std::uint64_t now,
now_ = now;
ExternalVector<std::uint8_t>().swap(page_);
status_ = reload ? "Invalidating cached page..." : "Checking page cache...";
lookup_admitted_ = false;
invalidation_admitted_ = false;
if (reload) {
state_ = CacheFlowState::INVALIDATE;
@@ -19,9 +20,14 @@ CacheFlowState NomadNetCacheFlow::begin(const CacheKey& key, std::uint64_t now,
}
return state_;
}
cache_.beginLookup(key_, now, false);
state_ = cache_.busy() ? CacheFlowState::LOOKUP : CacheFlowState::NEED_LIVE;
if (state_ == CacheFlowState::NEED_LIVE) status_ = "Requesting page...";
state_ = CacheFlowState::LOOKUP;
if (!cache_.busy()) {
lookup_admitted_ = cache_.beginLookup(key_, now, false) == CacheResult::PENDING;
if (!lookup_admitted_) {
state_ = CacheFlowState::NEED_LIVE;
status_ = "Requesting page...";
}
}
return state_;
}
@@ -45,6 +51,14 @@ void NomadNetCacheFlow::service() {
return;
}
if (state_ != CacheFlowState::LOOKUP || cache_.busy()) return;
if (!lookup_admitted_) {
lookup_admitted_ = cache_.beginLookup(key_, now_, false) == CacheResult::PENDING;
if (!lookup_admitted_) {
state_ = CacheFlowState::NEED_LIVE;
status_ = "Requesting page...";
}
return;
}
if (cache_.lastResult() == CacheResult::HIT && cache_.takeBody(page_)) {
state_ = CacheFlowState::READY;
status_ = "Cached page; current reachability not checked";