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

pkg/cache: Fix data races #2031

Merged
merged 1 commit into from
Sep 20, 2023
Merged

pkg/cache: Fix data races #2031

merged 1 commit into from
Sep 20, 2023

Conversation

javierhonduco
Copy link
Contributor

@javierhonduco javierhonduco commented Sep 19, 2023

Get() modify state, for LRU bookkeeping purposes, hence we need to use a writer lock.

Stop spawning goroutines for every callback as this introduces another data race.

Test Plan

The data races reported by tsan (make ENABLE_RACE=yes) are gone!

Both Kemal and myself have ran this code with a very small object pool
over night without any issues

@javierhonduco
Copy link
Contributor Author

Should fix #1962

pkg/cache/cache_with_eviction.go Show resolved Hide resolved
pkg/cache/cache_with_eviction.go Outdated Show resolved Hide resolved
@javierhonduco javierhonduco marked this pull request as draft September 19, 2023 16:29
Get() modify state, for LRU bookeeping purposes, hence we need to use a
writer lock.

Stop spawning goroutines for every callback as this introduces other
data races.

Test Plan
=========

The data races reported by tsan (make ENABLE_RACE=yes) are gone!

Both Kemal and myself have ran this code with a very small object pool
over night without any issues
@javierhonduco javierhonduco marked this pull request as ready for review September 20, 2023 08:47
@javierhonduco javierhonduco merged commit 3893091 into main Sep 20, 2023
22 checks passed
@javierhonduco javierhonduco deleted the cache-fix-races branch September 20, 2023 08:59
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.

None yet

3 participants