Repository navigation
sip: TestCallPark picks the parked party's dialog by Call-ID and fails a BYE on an ended dialog - #402
Merged
Merged
Conversation
…ID; fail a BYE on an ended dialog TestCallPark failed in the unit tier of CI run 44008466828 (PR #398, a store-only change) at park_test.go:433: "timed out waiting for BYE to the retriever when the parked party hangs up". It did not reproduce locally in about 2,000 runs: TestCallPark alone with and without -race, with -test.cpu=1, with random 0-300 ms delays injected at each step of retrieve, answer, BYE handling and linked hang-up, and in three full internal/sip package runs. The product path in that step is in order before the retriever's 200 goes out. parkRetrieved sets the parked call's peer (park.go:539), and handleRetrieve sets the retriever's link before answerSelf (park.go:633-636). After that, the parked party's BYE goes handleBye -> hangup -> linkedHangup -> notifyPeer -> the retriever's linkedHangup -> byeCallerRaw on every interleaving tried. The test has a gap that produces exactly this failure without a product bug. establish took the next INVITE and ACK queued for b, without checking whose they were. byeFrom then called sipgo's DialogServerSession.Bye, which returns nil without sending anything when the dialog has already ended (sipgo v1.7.3 dialog_server.go:364-368). So if b's queue gave establish another call's INVITE, step 4 got the step-3 dialog, which had already ended. byeFrom "succeeded" without sending a BYE, the PBX was never told the party hung up, and the wait for the retriever's BYE timed out after 10 s. The CI timing fits that: 16.64 s in total, which is the usual ~6.6 s for the earlier steps plus the 10 s wait. - establish drains b's INVITE and ACK queues before dialling. It then takes the INVITE sent by the PBX and the ACK with that INVITE's Call-ID. - byeFrom fails at once if the callee's dialog has already ended, instead of passing without sending a BYE. After: go test -race -count=50 -run 'TestCallPark$' ./internal/sip/ passes 50/50, and -race -count=3 -run TestCallPark (the whole park family) passes. The boss and session-timer tests that share establish and byeFrom also pass.
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.
TestCallPark failed in the unit tier of CI run 44008466828 (PR #398, a store-only change). The failure was at park_test.go:433: "timed out waiting for BYE to the retriever when the parked party hangs up".
Findings
No product race found. The failure did not reproduce in about 2,000 local runs:
-race, and with-test.cpu=1internal/sippackage runsOn every interleaving, the state the BYE needs is set before the retriever's 200 goes out:
parkRetrievedsets the parked call's peer atpark.go:539.handleRetrievesets the retriever's link beforeanswerSelf(park.go:633-636).The parked party's BYE then follows handleBye -> hangup -> linkedHangup -> notifyPeer -> the retriever's linkedHangup -> byeCallerRaw.
A test gap that gives exactly this failure.
establishtook whichever INVITE and ACK were next in b's queues, without checking which call they belonged to.byeFromcalled sipgo'sDialogServerSession.Bye. On a dialog that has already ended, that returns nil and sends nothing (sipgo v1.7.3dialog_server.go:364-368).So if a leftover request in b's queue gave step 4 the step-3 dialog, which had already ended,
byeFrom"succeeded" without sending a BYE. The PBX never learned that the party hung up, and the 10 s wait for the retriever's BYE timed out. The CI timing fits: 16.64 s in total, the usual ~6.6 s for steps 1-3 plus the 10 s wait.Changes
establishdrains b's INVITE and ACK queues before dialling. It then waits for the INVITE sent by the PBX and the ACK with that INVITE's Call-ID.byeFromfails at once if the callee's dialog has already ended, instead of passing without sending a BYE. If this flake comes back, it will now fail at the real cause.Verification
go test -race -count=50 -run 'TestCallPark$' ./internal/sip/: 50/50 pass.go test -race -count=3 -run TestCallPark ./internal/sip/(the whole park family): pass.establish/byeFromalso pass.Only
park_test.gochanges, so this does not conflict with #400'shelpers_test.gochange.