Repository navigation
Conversation
soujasK
force-pushed
the
fix/reset-peer-interrupt
branch
from
October 26, 2026 10:41
8aecdd6 to
2f3e64f
Compare
After the first chunk, reset_peer waited on time.After without selecting on Interrupt, so removing it (or adding a toxic after it) blocked for the whole timeout while holding the toxic collection's lock. With a timeout over the API's 25s limit the request failed with 503.
soujasK
force-pushed
the
fix/reset-peer-interrupt
branch
from
October 26, 2026 15:05
2f3e64f to
eb1137a
Compare
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.
Problem
Removing a
reset_peertoxic after it has received data blocks for the rest of itstimeout, and so does adding another toxic after it in the same direction. The collection lock is held the whole time, so with atimeoutover 25s the API request returns 503 and other toxic requests for that proxy block until the timer fires.Root cause
After reading the first chunk,
ResetToxic.Pipewaits with a bare<-time.After(timeout).InterruptToxicblocks until the running toxic receives fromInterrupt, whichreset_peerdoesn't select on while waiting, soRemoveToxic/AddToxic/UpdateToxicwait for the timeout.Solution
Select on
Interruptwhile waiting, and return without resetting when interrupted, the same wayslow_close,timeoutandlatencyhandle interrupts during their waits.Verification
TestRemoveResetPeerToxicDoesNotWaitForTimeout: areset_peerwith a 10s timeout receives a chunk, then is removed. Onmainthe removal is still blocked after 2s; with the change it returns right away.go test -racefor the root package and./toxics -run Reset(3 runs) pass; golangci-lint v2.14.0: 0 issues.Compatibility and risks
Removing a
reset_peerwhile its reset is pending now cancels the reset, instead of resetting the connection after the API call has been stuck for the timeout.If another toxic is added or updated while a reset is pending,
reset_peeris restarted and waits for the next chunk before starting its timeout again, so the reset is postponed until more data arrives. The other timer-based toxics behave the same way after an interrupt. Keeping the original deadline across restarts would need per-link state; I left that out to keep this small.May address some of the reports in #500.