Skip to content

Fix ConcurrentLfu Trim thread safety - #818

Merged
bitfaster merged 6 commits into
mainfrom
users/alexpeck/trimsafety
Aug 26, 2026
Merged

Fix ConcurrentLfu Trim thread safety#818
bitfaster merged 6 commits into
mainfrom
users/alexpeck/trimsafety

Conversation

@bitfaster

Copy link
Copy Markdown
Owner

PR #795 regressed ConcurrentLfu.Trim(n). In order to specify the item removed reason, TryRemove was switched to Evict. However, Evict is required to hold the maintenance lock.

Fix is to move all Evict calls inside the maintenance lock.

@bitfaster bitfaster changed the title Fix ConcurrentLfu trim thread safety Fix ConcurrentLfu Trim thread safety Aug 26, 2026
@coveralls

coveralls commented Aug 26, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 99.226% (+0.07%) from 99.158% — users/alexpeck/trimsafety into main

@RuneH-MSFT RuneH-MSFT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good. Left one minor comment.

Comment thread BitFaster.Caching.UnitTests/Lfu/TrimmingLfuCache.cs Outdated
@bitfaster
bitfaster merged commit b371a72 into main Aug 26, 2026
18 checks passed
@bitfaster
bitfaster deleted the users/alexpeck/trimsafety branch August 26, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConcurrentLfu.Trim races with AddOrUpdate in 2.6.0 and corrupts the LFU list

3 participants