Add an atomic.Bool to singleflight prefetching#7963
Merged
Conversation
thevilledev
approved these changes
Mar 28, 2026
thevilledev
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for the clean implementation @rpb-ant! I think compare-and-swap on the item is a more elegant approach than a separate sync.Map.
One small follow-up to consider: having a brief note in the plugin readme that concurrent background fetches for the same entry are deduplicated. Can be this PR or a separate one.
SuperQ
reviewed
Mar 28, 2026
Contributor
Author
|
I updated the plugin documentation, very open to feedback on phrasing. |
3c9aa7d to
0805bf3
Compare
Contributor
Author
|
Apologies for the missing DCO, fixed that and squashed everything down |
Also updated plugin to document single-flighting Signed-off-by: Ryan Brewster <rpb@anthropic.com>
0805bf3 to
96d49c5
Compare
Collaborator
|
Thanks @rpb-ant - merging 🥇 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
1. Why is this pull request needed and what does it do?
Follow-up to #7944
This ended up being fairly simple to implement, and my experiments indicate that it eliminates a significant footgun with both
prefetchandserve_stale2. Which issues (if any) are related?
#7904
3. Which documentation changes (if any) need to be made?
We probably want to update the docs around
prefetchandserve_stalejust to clarify that the background fetches are single-flighted4. Does this introduce a backward incompatible change or deprecation?
I don't believe so. Technically this is an observable change, but it should be a nearly strict improvement. I'd consider this more of an optimization than a breaking change.