Skip to content

Cancel pending origin connect on client abort#12999

Open
bneradt wants to merge 1 commit intoapache:masterfrom
bneradt:http2-rst-stream-abort-race
Open

Cancel pending origin connect on client abort#12999
bneradt wants to merge 1 commit intoapache:masterfrom
bneradt:http2-rst-stream-abort-race

Conversation

@bneradt
Copy link
Contributor

@bneradt bneradt commented Mar 19, 2026

The http2_rst_stream AuTest exposed a race on multiplexed origin
connects. If the client aborted while ATS was still queued on a shared
HTTP/2 origin handshake, HttpSM marked the transaction aborted but
stayed in the ConnectingEntry queue until later cleanup. A handshake
that finished in that window could still dispatch CONNECT_EVENT_TXN back
into the dead transaction, forwarding the request upstream and
producing an unexpected origin-side RST_STREAM.

Cancel the pending shared origin connect as soon as
state_watch_for_client_abort() records the client abort. That removes
the HttpSM from the ConnectingEntry queue before the handshake callback
can revive it, making the abort path deterministic and keeping the
aborted request from reaching origin.

The http2_rst_stream AuTest exposed a race on multiplexed origin
connects. If the client aborted while ATS was still queued on a shared
HTTP/2 origin handshake, HttpSM marked the transaction aborted but
stayed in the ConnectingEntry queue until later cleanup. A handshake
that finished in that window could still dispatch CONNECT_EVENT_TXN back
into the dead transaction, forwarding the request upstream and
producing an unexpected origin-side RST_STREAM.

Cancel the pending shared origin connect as soon as
state_watch_for_client_abort() records the client abort. That removes
the HttpSM from the ConnectingEntry queue before the handshake callback
can revive it, making the abort path deterministic and keeping the
aborted request from reaching origin.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a race in ATS’s multiplexed (HTTP/2) origin connect path where a client-aborted transaction could remain queued on a shared origin handshake and later get revived by a completed handshake callback, causing an unexpected upstream request and origin-side RST_STREAM.

Changes:

  • Cancel any queued multiplexed origin connect as soon as state_watch_for_client_abort() records a client abort (EOS as well as error/timeout paths).
  • Ensure aborted transactions are removed from ConnectingEntry::connect_sms early to prevent CONNECT_EVENT_TXN dispatch into a dead HttpSM.

tunnel.kill_tunnel();
// Drop any queued multiplexed origin connect immediately so a
// completed handshake cannot revive this transaction after the
// client has already aborted.
@@ -955,6 +959,7 @@ HttpSM::state_watch_for_client_abort(int event, void *data)
ATS_PROBE1(milestone_ua_close, sm_id);
milestones[TS_MILESTONE_UA_CLOSE] = ink_get_hrtime();
set_ua_abort(HttpTransact::ABORTED, event);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants