bug(connection): configuration transition silently consumes valid keepalive replies #2

Open
opened 2026-09-11 19:43:30 +00:00 by xymb-endcrystalme · 1 comment
Owner

A valid backend keepalive reply can be silently consumed during the CONFIG→PLAY transition. Reproduced locally against FasterVelocity 3b4be57f, using the real ClientConfigSessionHandler.handle(FinishedUpdatePacket), real ClientPlaySessionHandler.handle(KeepAlivePacket), and real ConnectedPlayer.forwardKeepAlive methods with mocked connections and a queued executor.

Sequence:

  1. A backend configuration keepalive is recorded in VelocityServerConnection.pendingPings.
  2. The client sends its Finish Configuration acknowledgement followed by the keepalive reply in the same read batch.
  3. ClientConfigSessionHandler.handle(FinishedUpdatePacket) immediately changes the client state to PLAY and completes configSwitchFuture.
  4. ConfigSessionHandler schedules the backend's switch to PLAY via thenRunAsync(..., smc.eventLoop()). Backend bootstrap explicitly uses the client's event loop, so the scheduled continuation can run after other already-buffered client packets.
  5. The next reply reaches ConnectedPlayer.sendKeepAliveToBackend with client PLAY / backend CONFIG. The method removes its ID from the pending map, fails the state check, and returns true without forwarding it.
  6. After the queued continuation, both sides are PLAY but the reply is gone: no forwarding, no retained pending entry, no diagnostic.

The local regression expectation that the valid reply must be forwarded or retained fails:

PROBE: buffered config reply: forwarded=0 pending=0 finalStates=PLAY/PLAY
3 tests completed, 1 failed

Controls (CONFIG/CONFIG and PLAY/PLAY) both pass. The expected failure concerns reply conservation, not a demand to write a CONFIG-encoded packet to a PLAY peer. A fix should preserve state-correct encoding while retaining/draining accepted replies through the transition. It should also define handling for closed/replaced backends; do not forward old connection replies to a replacement worker.

This investigation started from production player timeouts in 6b6t/Fox#193. The same method was verified in the on-disk production FasterVelocity 4.1.1 jar by extracting ConnectedPlayer.class and disassembling it locally. This proves the proxy defect and a deterministic local transition case, not that it explains every observed player timeout. In particular, fardy27 shows missing-response deadlines rather than out-of-order diagnostics, and Fox independently resets pending challenges on listener handoff.

Evidence: /home/xymb/6b_dev/DevelopmentFox/cache/keepalive-deep-20260911/probe.log, probe.init.gradle, and probe/com/velocitypowered/proxy/connection/client/KeepAliveTransitionProbeTest.java. Test-only sources were supplied from the ignored evidence directory using a Gradle init script. No production source or runtime changes, uploads, restarts, or JVM attach diagnostics were performed.

A valid backend keepalive reply can be silently consumed during the CONFIG→PLAY transition. Reproduced locally against FasterVelocity `3b4be57f`, using the real `ClientConfigSessionHandler.handle(FinishedUpdatePacket)`, real `ClientPlaySessionHandler.handle(KeepAlivePacket)`, and real `ConnectedPlayer.forwardKeepAlive` methods with mocked connections and a queued executor. Sequence: 1. A backend configuration keepalive is recorded in `VelocityServerConnection.pendingPings`. 2. The client sends its Finish Configuration acknowledgement followed by the keepalive reply in the same read batch. 3. `ClientConfigSessionHandler.handle(FinishedUpdatePacket)` immediately changes the client state to PLAY and completes `configSwitchFuture`. 4. `ConfigSessionHandler` schedules the backend's switch to PLAY via `thenRunAsync(..., smc.eventLoop())`. Backend bootstrap explicitly uses the client's event loop, so the scheduled continuation can run after other already-buffered client packets. 5. The next reply reaches `ConnectedPlayer.sendKeepAliveToBackend` with client PLAY / backend CONFIG. The method removes its ID from the pending map, fails the state check, and returns true without forwarding it. 6. After the queued continuation, both sides are PLAY but the reply is gone: no forwarding, no retained pending entry, no diagnostic. The local regression expectation that the valid reply must be forwarded or retained fails: ``` PROBE: buffered config reply: forwarded=0 pending=0 finalStates=PLAY/PLAY 3 tests completed, 1 failed ``` Controls (CONFIG/CONFIG and PLAY/PLAY) both pass. The expected failure concerns reply conservation, not a demand to write a CONFIG-encoded packet to a PLAY peer. A fix should preserve state-correct encoding while retaining/draining accepted replies through the transition. It should also define handling for closed/replaced backends; do not forward old connection replies to a replacement worker. This investigation started from production player timeouts in 6b6t/Fox#193. The same method was verified in the on-disk production FasterVelocity 4.1.1 jar by extracting `ConnectedPlayer.class` and disassembling it locally. This proves the proxy defect and a deterministic local transition case, **not** that it explains every observed player timeout. In particular, fardy27 shows missing-response deadlines rather than out-of-order diagnostics, and Fox independently resets pending challenges on listener handoff. Evidence: `/home/xymb/6b_dev/DevelopmentFox/cache/keepalive-deep-20260911/probe.log`, `probe.init.gradle`, and `probe/com/velocitypowered/proxy/connection/client/KeepAliveTransitionProbeTest.java`. Test-only sources were supplied from the ignored evidence directory using a Gradle init script. No production source or runtime changes, uploads, restarts, or JVM attach diagnostics were performed.
Author
Owner

Scope clarification from the user: do not accommodate arbitrary bot/client quirks. This issue's local probe establishes the code's behavior for a delayed reply crossing a protocol-state boundary, but a supported/vanilla client's production of that ordering is not yet established. Treat this as a conditional investigation, not sufficient justification to relax protocol-state checks or accept arbitrary stale replies.

The stronger confirmed vanilla compatibility case is 6b6t/Fox#196: a headless method-level probe using actual Minecraft26.2 client code reproduces a newer immediate reply overtaking an older deferred reply after window-event polling unfreezes. Its normal control passes, and Fox rejects that known-ID order. That case, together with the pending-queue correctness defect in 6b6t/Fox#195, should take priority. No fixes or production changes have been made.

Scope clarification from the user: do not accommodate arbitrary bot/client quirks. This issue's local probe establishes the code's behavior for a delayed reply crossing a protocol-state boundary, but a supported/vanilla client's production of that ordering is not yet established. Treat this as a conditional investigation, not sufficient justification to relax protocol-state checks or accept arbitrary stale replies. The stronger confirmed vanilla compatibility case is 6b6t/Fox#196: a headless method-level probe using actual Minecraft26.2 client code reproduces a newer immediate reply overtaking an older deferred reply after window-event polling unfreezes. Its normal control passes, and Fox rejects that known-ID order. That case, together with the pending-queue correctness defect in 6b6t/Fox#195, should take priority. No fixes or production changes have been made.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
6b6t/FasterVelocity#2
No description provided.