-
Notifications
You must be signed in to change notification settings - Fork 249
[narInfoCache] Use sync.Map and simplify IsInBinaryCache #1473
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0bc1dd6
[narInfoCache] Simplify IsInBinaryCache
mikeland73 f2542f9
Fix
mikeland73 252ffb6
Fix2
mikeland73 f9b3cca
Use sync.Map
mikeland73 7cada0b
Simplify more
mikeland73 7e527a4
Remove comment
mikeland73 4fc377e
Reduce race condition
mikeland73 e042a78
Fix race
mikeland73 c747352
Use once
mikeland73 fc483da
Bump go version
mikeland73 67d0f5b
comments
mikeland73 ad45762
simplify code
mikeland73 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be a race here where multiple goroutines see
alreadySet == false
before reaching line 93. Or one goroutine might reach line 93 and then another seesstatus.(bool) == false
on line 91.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I think our calling patterns make this unlikely but better to avoid if possible.
I think using
defer
might solve most race conditions. It's not immune to a success following a failure (but neither is the current code so it would not be a regression)