Repository navigation
Fix flaky SessionConfigLive static-exchange tests (#62) - #63
Conversation
…e tests SessionConfigLive.StaticExchangeDeliversBothPayloads failed intermittently (~2 in 10 on master) at the ID_NEW_INCOMING_CONNECTION assertion, always after burning the full 15s deadline. Root cause is in the test, not the library. In static mode SendSessionConfigResponse() releases the server's withheld ID_NEW_INCOMING_CONNECTION in the same step that it sends ID_SESSION_CONFIG to the client, so the server's connection packet is enqueued strictly before the client's ID_CONNECTION_REQUEST_ACCEPTED, which requires that message to make a round trip first. The test waited on the client with PumpUntil(), whose alsoPump drain discards every packet the other peer has queued. When the scheduler lands between the two enqueues, ID_NEW_INCOMING_CONNECTION is thrown away and the following wait can never observe it. Confirmed by instrumenting PumpUntil's discard path: under load, every failing run logged exactly one discarded ID_NEW_INCOMING_CONNECTION while waiting for ID_CONNECTION_REQUEST_ACCEPTED (6 discards, 6 failures). Both tests now use the existing PumpUntilBoth() helper, which was added for this hazard and which the rest of the suite already uses. Verified on macOS arm64 under the 8-way parallel load that reproduced the failure (5 failures in 115 runs before): 240/240 runs pass after the fix, plus SessionConfigLive.* --gtest_repeat=10 and the full 276-test ctest suite. Fixes #62
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe two session configuration integration tests now wait for both peers’ connection notifications together. They retain both packets and GUIDs before checking payload delivery or length. ChangesSession connection notification handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The changed tests collect both connection notifications before checking payloads. No merge-blocking issue was found in the inspected paths. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit waits as packets arrive, Comment |
Fixes #62.
Root cause — test defect, not a library bug
In static mode,
RakPeer::SendSessionConfigResponse()releases the server's withheldID_NEW_INCOMING_CONNECTIONin the same step that it sendsID_SESSION_CONFIGto the client. The client'sID_CONNECTION_REQUEST_ACCEPTEDis only produced once that message has crossed the wire and been parsed, so the server's connection packet is always enqueued first.StaticExchangeDeliversBothPayloadswaited on the client first withPumpUntil(), and that helper'salsoPumpdrain discards every packet the other peer has queued. Whenever the scheduler lands in the gap between the two enqueues,ID_NEW_INCOMING_CONNECTIONis thrown away, and the following wait then burns its full 15s deadline — exactly the reported symptom (line 280, ~15.2s).This is the hazard
PumpUntilBoth()was added for and already documents; these two tests were simply never converted.Evidence
Instrumented
PumpUntil's discard path and ran the test under 8-way parallel load:6 discards, 6 failures —
want=16isID_CONNECTION_REQUEST_ACCEPTED,id=19isID_NEW_INCOMING_CONNECTION. One-to-one.Fix
Both
StaticExchangeDeliversBothPayloadsandEmptyPayloadsStillConnect(same latent defect — the handshake runs with empty payloads too) now usePumpUntilBoth(). No library change; nothing was masked by a retry or a longer deadline.The interactive-mode tests are unaffected: they wait on the server's
ID_NEW_INCOMING_CONNECTIONfirst, which is the safe order given the enqueue ordering above.Verification (macOS arm64)
SessionConfigLive.*--gtest_repeat=10ctestSummary by CodeRabbit