Skip to content

[9.4] [ML] Fix concurrent LFU cache count invariant under lock timeouts (#3090)#3101

Merged
github-actions[bot] merged 1 commit into
9.4from
backport/9.4/pr-3090
Jul 23, 2026
Merged

[9.4] [ML] Fix concurrent LFU cache count invariant under lock timeouts (#3090)#3101
github-actions[bot] merged 1 commit into
9.4from
backport/9.4/pr-3090

Conversation

@github-actions

Copy link
Copy Markdown

Backport

This will backport the following commits from main to 9.4:

Questions ?

Please refer to the Backport tool documentation

)

The concurrent cache only incremented m_NumberLookups inside the read-guard
lambda, which does not run when the read lock times out. The subsequent miss
path can still add a count (insert/increment) or record a lost update, so under
contention the surviving counts could exceed the number of accounted lookups
and intermittently trip checkInvariants() (observed as a flaky failure of
testConcurrentReadsAndWrites on loaded debug CI agents).

Count every lookup exactly once, before taking the read lock. Also relax the
count invariant for the timeout-capable cache to a one-sided bound: counts can
legitimately be lost under concurrency (an item hit under the read lock may be
evicted before its count is incremented, one insert can evict several items,
and write updates can time out) but must never be fabricated. The exact
equality is retained for the single-threaded cache, which has no timeouts.

Add a regression test that drives lock timeouts via a zero maximum wait under
heavy contention; it fails reliably against the previous code.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
(cherry picked from commit 1beb813)
@edsavage

Copy link
Copy Markdown
Contributor

buildkite build

@edsavage edsavage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean cherry-pick of #3090 (reviewed + merged on main). Approving the backport.

@github-actions
github-actions Bot merged commit 32b85b1 into 9.4 Jul 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically merge backport PRs when CI passes backport >bug :ml v9.4.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants