Skip to content

Draft: 8386985: PacketSpaceManagerTest failed with AssertionError; A race condition may cause packetSent to mistakenly skip rescheduling of the transmitter task#31662

Open
dfuch wants to merge 1 commit into
openjdk:masterfrom
dfuch:PacketSpaceManager-8386985

Conversation

@dfuch

@dfuch dfuch commented Jun 24, 2026

Copy link
Copy Markdown
Member

The issue was observed on a local run in PacketSpaceManagerTest:

org.opentest4j.AssertionFailedError: nextDeadline should not be after 250ms from now! ==> expected: but was:
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
at org.junit.jupiter.api.Assertions.assertFalse(Assertions.java:239)
at PacketSpaceManagerTest$SynchronousTestDriver.run(PacketSpaceManagerTest.java:856)

Investigation suggests that this caused by a race condition where packetSent was invoked while the transmitter task was running: packetSent will only reschedule the transmitter if there is no deadline, that is, if it observes that deadline == Deadline.MAX; But if deadline is already in the past, which is typically the case when the transmitter task is running, then there's no guarantee that the transmitter task will actually end up rescheduling itself with a new deadline. It may not if it thinks there is nothing pending. The transmitter will then remain unscheduled until something else happens that causes it to be rescheduled. In a typical HTTP/3 request/response exchange chances are high that "something else" will happen, which explains why even if packetSent fails to rescedule, there might not be any observable consequence (outside of PacketSpaceManagerTest). However, there is no guarantee.

The fix is to always call PacketSpaceManager::reschedule, which will compute a new prospective deadline which the timer queue can reliably use to decide whether the selector should be woken up to take into account the new deadline.

A new testPacketSent() test that deterministically fails without the fix is added to PacketSpaceManagerTest.



Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31662/head:pull/31662
$ git checkout pull/31662

Update a local copy of the PR:
$ git checkout pull/31662
$ git pull https://git.openjdk.org/jdk.git pull/31662/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31662

View PR using the GUI difftool:
$ git pr show -t 31662

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31662.diff

…ndition may cause packetSent to mistakenly skip rescheduling of the transmitter task
@bridgekeeper

bridgekeeper Bot commented Jun 24, 2026

Copy link
Copy Markdown

👋 Welcome back dfuchs! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jun 24, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the net net-dev@openjdk.org label Jun 24, 2026
@openjdk

openjdk Bot commented Jun 24, 2026

Copy link
Copy Markdown

@dfuch The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

net net-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

1 participant