From e5fda7c657bbaa532ccbc27b9cf4a9886071abfb Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Wed, 31 Jul 2024 17:08:48 -0700 Subject: [PATCH] Allow Stale phase in cache_miss There could be a race condition where a Stale request waiting on cache lock retries the cache lock and lookup, but enters cache_miss after finding the asset is no longer present. --- .bleep | 2 +- pingora-cache/src/lib.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.bleep b/.bleep index 5b7d250..9ab32a4 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -0f6ff9925981892f544498c8b322cc66f55281c8 \ No newline at end of file +e68f6024370efed50aebc8741171956acabf9c35 \ No newline at end of file diff --git a/pingora-cache/src/lib.rs b/pingora-cache/src/lib.rs index 86cfbdf..a999f7e 100644 --- a/pingora-cache/src/lib.rs +++ b/pingora-cache/src/lib.rs @@ -493,7 +493,8 @@ impl HttpCache { match self.phase { // from CacheKey: set state to miss during cache lookup // from Bypass: response became cacheable, set state to miss to cache - CachePhase::CacheKey | CachePhase::Bypass => { + // from Stale: waited for cache lock, then retried and found asset was gone + CachePhase::CacheKey | CachePhase::Bypass | CachePhase::Stale => { self.phase = CachePhase::Miss; self.inner_mut().traces.start_miss_span(); }