Repository navigation
De-flake TcpConnectionOwnershipDisposalSpec: keep the close from finishing before the rejected write lands - #8661
Merged
Aaronontheweb merged 1 commit intoSep 29, 2026
Conversation
…shing before the rejected write lands An idle graceful close finishes in a few ms, so a test thread preempted between Close and Write could see the Write dead-lettered (Closed instead of CommandFailed). Park unread output first so the connection stays in ClosingBehaviour until the test drains it.
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.
OwnedWrite_ClosingBehaviour_rejection_disposes_owner_before_CommandFailedsendsClose, then an ownedWrite, and expects the Write to be rejected while the connection is closing.Race: on an idle connection the graceful close completes through self-messages (
TransportOperationCompleted,ReadPumpCompleted) within a few ms, and the actor stops. If the test thread is preempted between the two sends, which is realistic on 2-vCPU agents whereClosewakes 3–4 threads, the Write is dead-lettered. The handler getsClosedinstead ofCommandFailed, and the owner is never disposed. Same-sender FIFO doesn't help, because the messages that finish the close come from the actor itself.Fix (test only): before
Close, park 4 MB of output that the client doesn't read, using 16 KB socket buffers (the same technique asTcpConfirmedCloseSpec). The close can't finish until the test drains it, so the Write always lands in ClosingBehaviour. The test then drains, checks that the blocker arrives intact followed by EOF (the rejected bytes never hit the wire), and expectsClosedandTerminated. Every expectation in the test now has an explicit timeout.Verification:
Akka.Tests.IOfilter 5/5.DisposeOwnedSegmentson the ClosingBehaviour rejection path fails it 3/3.The other seven tests in the spec were checked for thread-level races (dispose counts use
Interlocked/Volatile, the pool is per test and thread-safe). None were found.