Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race in LRU concurrent update and TryRemove(kvp) #616

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

bitfaster
Copy link
Owner

@bitfaster bitfaster commented Jul 31, 2024

There is a lock in TryUpdate to prevent concurrent updates, but no item lock on TryRemove(kvp). No lock is needed for TryRemove(key) because updates to the value do not affect the outcome - key should always be removed. The value is important in the kvp variant however (#371), where the equivalent lock was missed leading to a race when the value changes between finding the existing LruItem and removing it.

@coveralls
Copy link

Coverage Status

coverage: 99.209%. remained the same
when pulling 0fbf72e on users/alexpeck/updremkvp
into f9563f8 on main.

@bitfaster bitfaster merged commit f682e88 into main Jul 31, 2024
13 checks passed
@bitfaster bitfaster deleted the users/alexpeck/updremkvp branch July 31, 2024 18:47
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.

TryRemove(KeyValuePair<K, V>) removes item even when value doesn't match
2 participants