Skip to content

Make TcpConnectionSpec pull-mode reads deterministic#3321

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix-3311-tcp-pull-mode-flake
Jul 11, 2026
Merged

Make TcpConnectionSpec pull-mode reads deterministic#3321
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix-3311-tcp-pull-mode-flake

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 10, 2026

Copy link
Copy Markdown
Member

Motivation

The TcpConnectionSpec pull-mode test assumed data written on the server side was immediately readable by the client. Under load, ResumeReading could perform a non-blocking read before the data arrived; it then registered OP_READ, but the test uses a probe as the connection selector and never delivered the later ChannelReadable notification.

Modification

Assert that each payload is written in full and use the test NIO selector to wait until the client channel is readable before each ResumeReading command.

Result

The test still verifies that pull mode emits exactly one Tcp.Received per pull while no longer depending on loopback delivery timing.

References

Fixes #3311

Motivation:
TcpConnectionSpec assumed data written on the server side was immediately readable by the client before ResumeReading. Under load, the non-blocking client read could return zero and the fake selector never delivered the later ChannelReadable notification.

Modification:
Assert each test payload is written in full and wait for the client channel to become readable before each pull-mode ResumeReading command.

Result:
The test preserves its one-Received-per-pull assertions without depending on loopback delivery timing.

Tests:
- JDK 25 focused pull-mode test, 10 consecutive runs: passed
- JDK 25 full TcpConnectionSpec: 35 passed, 0 failed
- sbt headerCreateAll +headerCheckAll checkCodeStyle: passed
- scalafmt --list --mode diff-ref=origin/main: passed
- git diff --check: passed
- Qoder stdout review: no must-fix findings

References:
Refs apache#3311
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jul 11, 2026

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit 57983ca into apache:main Jul 11, 2026
10 checks passed
@He-Pin He-Pin deleted the fix-3311-tcp-pull-mode-flake branch July 11, 2026 10:16
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.

Flaky TcpConnectionSpec pull-mode test times out waiting for Tcp.Received

2 participants