fix(request-sharing): correct clone, gc task lifetime, and drop zeroing for RequestSharing#4411
Open
metalurgical wants to merge 3 commits into
Open
fix(request-sharing): correct clone, gc task lifetime, and drop zeroing for RequestSharing#4411metalurgical wants to merge 3 commits into
metalurgical wants to merge 3 commits into
Conversation
…g independent one Additionally, gc task exits when all handles dropped, drop only zeroes on last handle
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the RequestSharing implementation to share the in-flight request cache across clones and modifies the garbage collection task to use a weak reference, ensuring the task terminates when all handles are dropped. A critical race condition was identified where the request_sharing_cached_items metric might remain at a non-zero value if the GC task holds a strong reference during the final drop of the cache handles. It is recommended to explicitly zero the metric within the GC task's exit path to ensure consistent state reporting.
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.
Description
Correct
Cloneimplementation forRequestSharingto share the in-flight cache instead of creating a new one, allow the GC task to exit when all handles are dropped, and fixDropto only zero on the last handle.Changes
in_flight: self.in_flight.clone()instead ofDefault::default()spawn_gcmodified to checkArcand exit once all handles are gone.Arc::strong_count(&self.in_flight) == 1How to test
cargo nextest run -p request-sharing