Skip to content

fix(semantic-cache): serialise index bucket writers under a cache-level lock - #41824

Closed
mikebridge wants to merge 6 commits into
apache:sl-cachefrom
mikebridge:pr-40221-atomic-index-updates
Closed

mikebridge wants to merge 6 commits into
apache:sl-cachefrom
mikebridge:pr-40221-atomic-index-updates

Conversation

@mikebridge

@mikebridge mikebridge commented Jul 6, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Contribution into #40221's branch (sl-cache), addressing @rusackas's twice-flagged review finding: store_result performs a non-atomic read-modify-write on the index bucket, so two concurrent writers for one view can clobber each other's entries. The eviction prune in try_serve_from_cache has the same shape and can actively drop an entry added between its read and write.

Why not WATCH/MULTI or Lua (the original suggestion): the index value is a pickled Python list managed through the Flask-Caching abstraction, and data_cache is not guaranteed to be Redis-backed. Lua can't merge pickled payloads, and WATCH requires reaching into Redis-only client internals.

The fix: a short-lived lock key acquired via cache.add — the portable set-if-absent primitive (SETNX on Redis, add on memcached) — serialises index writers per bucket. The invariant, honestly scoped: on backends where add is atomic, the index is only written while holding the lock, with two narrow best-effort windows (the non-atomic get-compare-delete in the release/break fences, and cross-worker clock skew beyond the 30 s stale threshold), both bounded to the pre-fix benign lost-entry — never wrong data. On acquisition timeout (~500 ms of sleeps plus backend round-trips) the update is skipped — losing at most that write's future cache benefit — rather than performed unlocked, which could clobber a concurrent writer. Backends without add() degrade to the previous behavior. Both store_result and the prune path go through the same helper (_update_index), and the prune re-reads under the lock instead of writing back a stale list.

Hardening from two review rounds (both panels' findings and resolutions are in the PR comments): the lock value is an owner token minted per acquisition attempt (release and stale-break are both fenced by compare-before-delete); locks orphaned without a TTL (cachelib RedisCache.add is SETNX-then-EXPIRE, so a holder killed between the two leaves one) are broken after 15×TTL, with math.isfinite guarding against never-stale :nan values and the threshold sized for cross-worker clock skew; the eviction prune performs zero backend calls inside the lock (it prunes exactly the value keys the candidate loop observed missing) and clean cache hits take no lock at all; skipped registrations log at warning.

TESTING INSTRUCTIONS

Nine dedicated tests, every one validated to fail under the exact mutation or pre-fix code it guards:

  • Four event-choreographed concurrency tests (no timing dependence; independently verified 30/30 consecutive green runs, and 4/4 red against the base branch): store-vs-store clobber, timeout-skip invariant (busy lock → the index is never written unlocked), abandoned-TTL-less-lock breaking, and prune-vs-store (the locked re-read keeps a concurrently stored entry while dropping the dead one).
  • Five protocol kill-tests: the release fence declines a foreign token; the stale-breaker does not fire on a fresh foreign lock; every lock add carries the TTL; clean cache hits perform zero lock operations; and the staleness parser's nan/inf/boundary edges.
pytest tests/unit_tests/semantic_layers/ -q   # 388 passed

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

…el lock

Addresses @rusackas's twice-flagged review finding on apache#40221: store_result
performed a non-atomic read-modify-write on the index bucket, so two
concurrent writers for one view could clobber each other's entries; the
eviction prune in try_serve_from_cache had the same shape and could
actively drop an entry added between its read and write.

A Redis WATCH/Lua transaction can't be used here: the index value is a
pickled Python list managed through the Flask-Caching abstraction, and
the data cache is not guaranteed to be Redis-backed. Instead, a
short-lived lock key acquired via cache.add (SET NX on Redis, add on
memcached) serialises index writers per bucket, with a hard invariant:
when the backend supports add(), the index is only written while holding
the lock — on acquisition timeout the update is skipped (losing at most
one write's future cache benefit) rather than performed unlocked, which
could clobber a concurrent writer. Backends without add() degrade to the
previous unlocked behavior.

The new test choreographs the exact historical interleaving with events
(no timing dependence): thread A parked inside its index read while
thread B stores for the same view, then A resumes. Validated
bidirectionally — without the fix it fails every run with B's entry
clobbered by A's stale write; with the fix both entries survive
(B blocks on the lock, releases A, then appends). Full semantic_layers
suite: 374 passing.
@dosubot dosubot Bot added the infra:caching Infra setup and configuration related to caching label Jul 6, 2026
@bito-code-review

bito-code-review Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at [email protected].

@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit e20d48d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a4c12295318dd0008aedc8b
😎 Deploy Preview https://deploy-preview-41824--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 17.50000% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.41%. Comparing base (5581315) to head (93a9796).

Files with missing lines Patch % Lines
superset/semantic_layers/cache.py 17.50% 66 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           sl-cache   #41824      +/-   ##
============================================
- Coverage     63.43%   63.41%   -0.03%     
============================================
  Files          2592     2591       -1     
  Lines        138780   138715      -65     
  Branches      32235    32229       -6     
============================================
- Hits          88038    87968      -70     
- Misses        49212    49226      +14     
+ Partials       1530     1521       -9     
Flag Coverage Δ
hive 39.21% <17.50%> (-0.05%) ⬇️
mysql 58.74% <17.50%> (-0.05%) ⬇️
postgres 58.82% <17.50%> (-0.06%) ⬇️
presto 40.90% <17.50%> (-0.04%) ⬇️
python 59.06% <17.50%> (-0.06%) ⬇️
sqlite 58.46% <17.50%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mikebridge

Copy link
Copy Markdown
Member Author

Multi-lens self-review (posting for transparency before anyone spends review time)

We ran this PR through a six-lens parallel review panel (Python, committer, CD, clean-code, tidy-first, Amin-style scans) and verified every load-bearing claim against the pinned cachelib 0.13.0 source. Verdicts: 0 blockers, unanimous approve-with-changes — the invariant, skip-not-clobber choice, and deterministic test were endorsed by all six, but the panel found real hardening gaps. Findings below; a follow-up commit addressing them is queued.

HIGH (all independently found by multiple lenses)

  1. Unconditional read-path locking (6/6 lenses) — try_serve_from_cache invokes the locked prune on every read with a non-empty bucket, scanning up to 128 full pickled payloads inside the lock just to test existence. Readers serialize; writers can exhaust their retry budget behind reader prunes and skip — losing more cache benefit than the race being fixed. On SupersetMetastoreCache each lock attempt is a metadata-DB INSERT+commit. Fix: gate the prune on actually-observed eviction (the candidate loop already sees payload is None), single non-blocking attempt on the read path, cache.has() (with fallback — BaseCache.has raises NotImplementedError) instead of get().

  2. Unfenced lock release (6/6) — if a critical section outlives _INDEX_LOCK_TIMEOUT=2s, a successor legitimately acquires the lock; the original holder's unconditional finally: cache.delete(lock_key) then releases the successor's lock, and its late cache.set writes unlocked — so the docstring's "only ever written while holding the lock" overclaims. Fix: per-acquisition token, compare-before-delete; the has() change collapses the hold time that makes expiry plausible.

  3. Crash-orphaned lock (3 lenses; verified in cachelib source) — RedisCache.add is SETNX followed by a separate EXPIRE. A process killed between the two leaves a TTL-less lock, and with skip-on-timeout that means every index update for the bucket is silently skipped forever (debug-level log only) until the view's changed_on rotates the key. Fix: store a timestamp token as the lock value and break locks older than k×TTL on repeated failure; raise repeated-skip logging to warning.

MEDIUM

  • An exception escaping the prune's lock machinery now propagates to the outer except → return None, discarding an already-computed cache hit — housekeeping needs its own try/except.
  • Two mutation-testing gaps: the timeout-skip invariant is untested (mutating the skip into a fall-through passes the whole suite), and the prune half of the race has no regression test — both cheap with the existing _RacingCache harness.
  • Lock-skip/degraded events are unobservable in production; and the "backend without add" branch is unreachable (Flask-Caching always exposes it) — the real degradation is backends whose add isn't atomic (BaseCache.add returns True unconditionally; SimpleCache.add is check-then-act), which the docstring should state.

LOW (condensed)

Orphaned value blob when a store's index write is skipped (worth a comment; deleting is unsafe) · cache: Any → flask_caching.Cache or a small Protocol · test-harness inline imports / Any-typed events · a harness assertion can be swallowed by store_result's defensive except, yielding a misleading failure message · patch _INDEX_LOCK_ATTEMPTS up inside the test for slow-CI headroom.


What the panel endorsed (unchanged in the follow-up): skip-on-timeout as "the correct half of the invariant" (writing unlocked on timeout would reintroduce the clobber exactly under contention); the harness releasing the parked thread from inside a failed add() (proving the lock is engaged rather than inferring from timing); one _update_index helper for both writers; the prune re-reading under the lock. Mutation spot-checks confirmed the existing test kills the four primary regressions.

🤖 Generated with Claude Code

Addresses every finding from the multi-lens review posted on the PR:

1. Read path stays lock-free on clean hits (6/6 lenses): the prune is
   gated on having actually observed an evicted value in the candidate
   loop, uses a single non-blocking lock attempt (it is opportunistic —
   a missed prune retries on the next read that observes the eviction),
   checks existence via cache.has() (Redis EXISTS; falls back to get()
   where has() is unavailable or unimplemented) instead of fetching full
   pickled payloads, and is isolated in its own try/except so
   housekeeping can never turn a computed cache hit into a miss.

2. Fenced release (6/6): the lock value is now an owner token; release
   deletes only on token match, so a holder that outlives the TTL cannot
   free a successor's lock. With has() collapsing the critical section,
   TTL expiry itself becomes implausible.

3. Abandoned-lock breaking (verified against cachelib 0.13.0):
   RedisCache.add is SETNX then a separate EXPIRE, so a holder killed
   between the two leaves a TTL-less lock that would freeze the bucket's
   index updates until changed_on rotates the key. The token embeds its
   acquisition timestamp; waiters break locks older than
   _INDEX_LOCK_STALE_FACTOR x TTL (with a warning).

4. Observability: a skipped store registration logs at warning with the
   index key (and a comment documents the orphaned-value-until-TTL
   trade-off); the docstring now scopes the invariant honestly to
   backends with atomic add and names the best-effort degradation on
   SimpleCache/NullCache.

Tests — all mutation-validated (each fails under the exact mutation it
guards): timeout-skip invariant (lock permanently busy with a fresh
foreign token -> index never written unlocked); abandoned TTL-less lock
is broken; prune-vs-store race (reader parked in its unlocked index
read while a writer stores -> the locked re-read keeps the new entry
while dropping the dead one). Harness hardened per review: module-level
imports, typed events, harness_errors surfaced instead of being
swallowed by production defensive excepts, and the retry budget patched
up in-test for slow-CI headroom. Full semantic_layers suite: 377.
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Jul 6, 2026
@mikebridge

Copy link
Copy Markdown
Member Author

Follow-up pushed in 47c50d169c — every panel finding above is addressed:

Finding Resolution
H1 read-path locking (6/6) Prune gated on observed eviction (clean hits never touch the lock), single non-blocking attempt, cache.has() with get() fallback, extracted to _prune_evicted and isolated so housekeeping can never turn a computed hit into a miss
H2 unfenced release (6/6) Owner-token lock values; release deletes only on token match; has() collapses the critical section so TTL expiry is no longer plausible
H3 crash-orphaned lock (verified vs cachelib 0.13.0) Token embeds its acquisition timestamp; waiters break locks older than 2×TTL with a warning
MED prune-exception → lost hit Own try/except in _prune_evicted
MED untested invariants Three new mutation-validated tests: timeout-skip (lock busy with a fresh foreign token → index never written unlocked), abandoned-TTL-less-lock breaking, and the prune-vs-store race (reader parked in its unlocked read while a writer stores → the locked re-read keeps the new entry, drops the dead one). Each fails under the exact mutation it guards — including one test the mutation check itself caught mis-armed and fixed before it shipped
MED observability Skipped store registrations log at warning with the index key; stale-lock breaks log at warning
LOWs Honest docstring (invariant scoped to atomic-add backends; SimpleCache/NullCache best-effort degradation named), orphaned-value trade-off comment, cache: Cache typing, module-level test imports, typed events, harness errors surfaced instead of swallowed, in-test retry budget for slow CI

Full semantic_layers suite: 377 passing.

@mikebridge

Copy link
Copy Markdown
Member Author

Round-2 review (six-lens panel, run via Claude)

Re-ran the same six-lens review panel over the cumulative diff after the hardening commit, with an adversarial brief: verify the round-1 fixes hold and hunt for defects the new code introduced. Full disclosure: this is an AI-generated review (Claude), with every load-bearing claim verified against source or by execution.

Round-1 findings: all resolved, 6/6 lenses — two verified empirically. One lens re-ran the suite in an isolated worktree (73/73, ruff clean); another ran the four concurrency tests 30/30 consecutive passes (0.42–0.80 s, no sleeps in the pass path) and confirmed all four fail fast against the base branch (0.73 s, no hangs) — genuinely pinning, CI-safe.

New findings — all in the round-2 hardening code itself (each degrades to the pre-fix benign lost-entry, never wrong data; fixes queued as round 3):

  1. Token timestamp is minted before the retry loop (2 lenses) — a slow acquisition yields a lock that is stale at birth and immediately breakable → two holders. The docstring says "acquisition timestamp"; the code implements generation time. Fix: mint per attempt.
  2. The stale-lock break is delete-then-add, unfenced (6/6 lenses; one built a threaded repro demonstrating the double-acquire — and showing the release fence correctly contained the cascade) — two waiters can both observe the stale value and the loser's delayed delete removes the winner's fresh lock. Fix: re-get-compare before delete, scope the docstring, log breaks at info (herd storms).
  3. The prune holds the lock across O(entries) backend round-trips (5 lenses) — up to 128 sequential existence checks can approach the 2 s TTL on slow links, contradicting the "critical section far under the TTL" justification. Fix: collect the dead value-keys already observed in the candidate loop and prune only those — zero backend calls inside the lock.
  4. 4 s staleness threshold is a thin clock-skew tolerance (4 lenses) — a waiter 4 s ahead breaks every live lock it sees. Fix: raise the factor; the guarded failure (frozen bucket) is the rarer event.
  5. Mutation-testing gaps (4 lenses): the release fence is currently unfalsifiable (a blind-delete mutation survives the suite); the breaker-not-fired property is claimed but unasserted; the lock TTL is unobserved; the clean-hit-lock-free property is unpinned. Fix: a batch of kill-tests, each one fake-tweak.
  6. Assorted: "token:nan" parses as never-stale (an unbreakable wedge — math.isfinite guard); the break's continue consumes the only attempt on the prune path; two docstring/log-wording overclaims; the PR body predates the hardening commit and will be refreshed.

CI note: the red pre-commit at HEAD is an infra flake (the "Enable brew and helm-docs" setup step died with "Broken pipe" before any hook ran) — will re-trigger.

Verdicts: SHIP ×1, approve ×2, approve-with-nits ×2, polish-first ×1 · 0 blockers.

Closes every finding from the round-2 six-lens review (posted on the PR):

1. Lock tokens are minted per acquisition attempt, so the embedded
   timestamp reflects acquisition time — a token minted once before a
   slow retry loop could be stale at birth, making the just-acquired
   lock immediately breakable.

2. The stale-lock break is best-effort fenced (re-read and compare
   before delete) and retries the add immediately within the same
   iteration — so a single-attempt caller that breaks an orphan gets
   its own acquisition instead of donating the break. Break logging
   demoted to info (a waiter herd breaking one lock is not a fault).
   The residual multi-breaker window is documented alongside the
   release fence's, and the _update_index invariant docstring now
   names both best-effort windows explicitly.

3. The prune performs ZERO backend calls inside the lock: the dead
   value keys are exactly those the candidate loop already observed
   missing, so the critical section is a constant get + membership
   filter + set regardless of bucket size. _value_exists is removed
   outright (nothing needs per-entry existence checks anymore).
   Entries that never match a query linger until TTL/trim — an
   accepted, documented trade for lock-free clean hits.

4. Staleness threshold raised (factor 2 -> 15, i.e. 30s): the
   timestamp is compared across workers' wall clocks, and 4s was a
   thin NTP tolerance for a correctness threshold — a waiter running
   ahead would break every live lock it saw. The frozen-bucket event
   this delays is the rarer one. math.isfinite guard added:
   float("nan") parses and compares False against any threshold,
   making a ":nan" lock value fresh forever — an unbreakable wedge.

5. Mutation-testing gaps closed with five new kill-tests, each
   validated to fail under the exact mutation it guards: blind-delete
   release (fence), breaker firing on a fresh foreign lock, lock add
   without TTL, prune on clean hits (zero lock ops pinned), and the
   nan/inf/boundary staleness edges.

6. Hygiene: superset-internal test imports hoisted to module top
   (making the round-2 resolution claim accurate), skip-warning
   wording corrected ("may be unreachable" — an earlier entry can
   reference the same canonical value key).

Full semantic_layers suite: 388 passing.
@mikebridge

Copy link
Copy Markdown
Member Author

Round 3 pushed in 7affd4e624 — every round-2 finding resolved:

Round-2 finding Resolution
Token timestamp minted before the retry loop Minted fresh per attempt (_mint_token), so the timestamp is genuinely acquisition time
Unfenced stale-break (6/6 lenses, one threaded repro) Compare-before-delete fencing on the break path, immediate in-iteration add retry (a single-attempt caller that breaks an orphan gets the acquisition rather than donating it), break log at info, residual multi-breaker window documented next to the release fence's
Prune O(entries) round-trips under the lock (5 lenses) Zero backend calls inside the lock: prunes exactly the value keys the candidate loop observed missing (constant get + membership filter + set). _value_exists deleted outright — which also retires the "has() branch never executed" test gap by removing the branch
4 s staleness threshold vs clock skew (4 lenses) Factor raised to 15 (30 s), with the skew trade-off documented on the constant
"token:nan" never-stale wedge math.isfinite guard
Mutation gaps: fence unfalsifiable, breaker-not-fired unasserted, TTL unobserved, clean-hit-lock-free unpinned, staleness edges Five new kill-tests, each validated to fail under the exact mutation it guards (blind-delete release, always-stale breaker, TTL-less add, always-prune, isfinite removal)
Docstring/wording overclaims; function-scoped test imports; stale PR body Invariant docstring names both best-effort windows explicitly; "may be unreachable" wording; superset imports hoisted to module top; PR body refreshed to the three-commit state

Suite: 388 passing. CI is running fresh on this head (the previous red was an infra flake in the brew setup step, pre-hooks).

Round 4, from an independent second-model review plus live-Redis
validation of the whole protocol:

1. The prune now drops the EXACT entries observed dead (frozen-dataclass
   identity, timestamp included) instead of every entry sharing the
   value key. A concurrent store_result re-executing the same query
   re-registers the SAME canonical value key with a fresh entry and a
   live value; the key-based prune introduced in round 3 would have
   dropped that fresh registration. Zero-backend-calls-under-lock is
   preserved. Pinned by a deterministic choreography test (reader
   parked at the moment it observes the missing value; writer
   re-stores the same query; the fresh registration must survive) —
   fails under the key-based mutation.

2. The single-attempt stale-break retry is pinned: a one-attempt
   caller (the prune path) that breaks a TTL-less orphan must complete
   its own update in the same attempt, not donate the break — removing
   the in-iteration retry now fails a test.

3. The staleness boundary is pinned with frozen time (exactly-at-
   threshold is NOT stale; the > -> >= mutation now fails).

4. The _update_index docstring names the third best-effort window
   (plain TTL expiry if the locked get+set itself stalls past the
   TTL), alongside the fence and clock-skew windows.

Live-Redis validation (real cachelib RedisCache, dev-stack Redis):
8 threads x 40 contended updates on one bucket -> 320/320 entries,
zero losses, zero skips; a genuine TTL-less SETNX orphan broken and
recovered; the release fence declining a foreign token; a fresh
foreign lock skipped in <1 ms without being broken; the acquired
lock carrying a real 2 s Redis TTL.

Full semantic_layers suite: 390 passing.
@mikebridge

Copy link
Copy Markdown
Member Author

Final validation round pushed in beeb91ac83 — two independent validators beyond the review panels:

Independent second-model review (OpenAI Codex, adversarial) found one real race the panels missed — introduced by round 3's own optimization: the key-based prune could drop a freshly re-registered same-key entry (a concurrent store_result re-executing the same query re-registers the same canonical value key with a live value). Fixed by pruning on entry identity (frozen dataclass, timestamp included) — zero-backend-calls-under-lock preserved — and pinned by a deterministic choreography test that fails under the key-based mutation. Its three smaller items are also in: the single-attempt stale-break retry is now pinned by a test, the staleness boundary is pinned with frozen time (>→>= now fails), and the docstring names the third best-effort window (plain TTL expiry of a stalled critical section).

Live-Redis validation (real cachelib.RedisCache against the dev-stack Redis — the protocol had only ever run against in-memory fakes):

  • 8 threads × 40 contended updates on one bucket → 320/320 entries, zero losses, zero skips, 0.65 s
  • A genuine TTL-less SETNX orphan (created via cachelib's own serializer, verified TTL == -1) broken and recovered by the next writer
  • The release fence declining a real foreign token; a fresh foreign lock skipped in 0.6 ms without being broken; the acquired lock carrying a real 2 s Redis TTL

Suite: 390 passing — twelve dedicated lock-protocol/concurrency tests, every one validated to fail under the exact mutation or pre-fix code it guards.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mikebridge, LGTM. Pulled the branch and ran it locally... 86/86 green, and the event-choreographed concurrency tests are deterministic rather than sleep-and-hope, which I appreciate.

For anyone puzzled by the failing CI: it's the 100% coverage gate on superset/semantic_layers/, which sl-cache already fails at the same 87 before this PR... cache.py actually goes up here (74% → 77%), so it's inherited, not introduced. Worth settling before the feature branch heads to master though. CC @betodealmeida

Review-panel finding on the sibling force-store PR (apache#41826): candidates
were ranked by reuse mode only, and Python's stable sort preserves
insertion order within a rank — so an OLDER stale broader entry that
also satisfies the query (EXACT-with-leftovers) was served ahead of a
just-forced fresh entry for the identical query. The forced refresh
never stuck for readers.

Tie-break by entry timestamp, freshest first. Pinned by a test with a
deterministically older same-rank broader entry — fails under the
rank-only sort.
…nches

Three edges for the 100% coverage gate (the rest of the gap is closed by
the sibling coverage PR into sl-cache): a lock that vanishes between the
failed add and the staleness read (plain retry, not a stale-break); the
fenced break declining when the lock changed hands between the staleness
read and the re-read; and the degraded no-add path skipping the write
when mutate returns None.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM. The freshest-first tie-break on same-rank candidates (from the #41826 review) is a real fix, and the choreographed test pins it well. The last few tests just fill in partial coverage branches, no new production code there.

@mikebridge

Copy link
Copy Markdown
Member Author

Supersession note to prevent accidental merge: #42760 is the consolidated replacement under review and explicitly carries forward the still-valid work and attribution from this PR stack. This does not mean #42760 has been accepted for adoption yet; that decision remains pending. Please do not merge this stacked PR while the consolidation decision is open; a maintainer or PR owner can close it and reopen later if the direction changes.

@mikebridge

Copy link
Copy Markdown
Member Author

Closing: this was a contribution into #40221's sl-cache branch, and #42760 has since replaced that branch as the semantic-layer containment cache. #42760 retains this fix — owner-safe descriptor mutation and the concurrency regressions — via lease-based coordination in cache_coordination.py (see the "Superseded PR → contribution retained" table in its description). The approval here stands as review evidence for the behaviour; nothing further is needed on this PR.

Closed by Claude (AI) on behalf of @mikebridge.

@mikebridge mikebridge closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra:caching Infra setup and configuration related to caching size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants