Skip to content

sip: TestCallPark picks the parked party's dialog by Call-ID and fails a BYE on an ended dialog - #402

Merged
piwi3910 merged 2 commits into
mainfrom
fix/park-bye-flake
Nov 17, 2026
Merged

piwi3910 merged 2 commits into
mainfrom
fix/park-bye-flake

Conversation

@piwi3910

Copy link
Copy Markdown
Contributor

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:

  • TestCallPark on its own, with and without -race, and with -test.cpu=1
  • random 0-300 ms delays injected into retrieve, answerSelf, handleBye and the linked hang-up goroutine
  • three full internal/sip package runs

On every interleaving, the state the BYE needs is set before the retriever's 200 goes out:

  • parkRetrieved sets the parked call's peer at park.go:539.
  • handleRetrieve sets the retriever's link before answerSelf (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.

  • establish took whichever INVITE and ACK were next in b's queues, without checking which call they belonged to.
  • byeFrom called sipgo's DialogServerSession.Bye. On a dialog that has already ended, that returns nil and sends nothing (sipgo v1.7.3 dialog_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

  • establish drains 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.
  • byeFrom fails 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.
  • The boss and session-timer tests that share establish/byeFrom also pass.

Only park_test.go changes, so this does not conflict with #400's helpers_test.go change.

…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.
@piwi3910
piwi3910 merged commit 5de7386 into main Nov 17, 2026
29 checks passed
@piwi3910
piwi3910 deleted the fix/park-bye-flake branch November 17, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant