Repository navigation
Hand an aborted leader's fetch to one follower instead of all of them [patch] - #110
Merged
Merged
Conversation
… [patch] When a leader's client disconnected mid-transfer, its followers were released with a failure and each fetched the object from upstream itself: the aborted fetch plus one per follower. A follower released without the object now acquires again, so one of them becomes the new leader and the rest wait for it, bounded at three leaders before a follower fetches for itself. The single flight retires an entry before releasing its followers, so a follower that acquires again gets a fresh entry rather than the finished one. Fixes #58 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ft9gJVQx6JFNQ4VRoAwd9
|
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.



Fixes #58
What
If a leader's client disconnected mid-transfer,
Ticket.Disposereleased its followers withfalse. Each follower then fetched the object from upstream on its own, so 1 leader and 5 followers produced 6 upstream fetches.This implements the issue's first option.
ObjectRouteHandler.DownloadAsync: a follower released without the object (an aborted or failed leader, or aFollowerTimeout) disposes its ticket and callscoalescer.Acquireagain. One released follower becomes the new leader and the others wait for it. The loop is bounded byMaxFollowerAttempts = 3; after that a follower fetches for itself, as it did before, so a run of failing leaders can't hold a request forever. Thecoalesced_waitsmetric is still recorded once per request.SingleFlight:CompleteandDisposenow retire the entry before they set its result. Before, a released follower that re-acquired quickly could find the finished entry still registered and get a follower ticket whose result was alreadyfalse. That wasted one of its attempts.I did not do the second option, which runs the leader's fetch on a token that isn't tied to its client. It would mean detaching the upstream fetch-and-store from the response stream the leader is writing. That is a larger change, and this fix already meets the acceptance criterion without it.
Tests
ProxyFlowTests.AbortedLeader_HandsTheFetchToOneFollowerInsteadOfEveryFollowerFetchingis the issue's repro. It holds the upstream behind a gate, queues 5 followers behind a leader, cancels the leader's request and then opens the gate. It asserts that every follower gets the right bytes and that upstream saw exactly 2 fetches. Acoalesced_waitsmeter listener confirms the followers are queued before the abort.StubUpstreamhas a newObjectGatethat holds object fetches in flight. A fetch whose request is cancelled while it waits is abandoned.Verification
mainatAssert.AreEqual(2, FetchCount), and passes with the fix.ConcurrentMissesForOneObject_ProduceASingleUpstreamFetch.#107 also edits
ObjectRouteHandler, but in the store-hit path, so any conflict should be small.🤖 Generated with Claude Code
https://claude.ai/code/session_017ft9gJVQx6JFNQ4VRoAwd9
Generated by Claude Code