Skip to content

pool: abort the HTTP connection when an HTTP-TPC pull is cancelled - #8327

Open
geonmo wants to merge 1 commit into
dCache:masterfrom
geonmo:fix/http-tpc-cancel-abort
Open

geonmo wants to merge 1 commit into
dCache:masterfrom
geonmo:fix/http-tpc-cancel-abort

Conversation

@geonmo

@geonmo geonmo commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #8301.

Problem

The remote-HTTP mover copies the GET response body with HttpEntity#writeTo. When the copy fails (for example the mover is cancelled and the replica write throws ClosedByInterruptException), BasicHttpEntity#writeTo closes the content stream in finally, and ContentLengthInputStream#close() reads the rest of the body from the remote server. That blocking read is not stopped by the interrupt. The mover stays CANCELED until the whole file has arrived, holds an HTTP-TPC connection slot, and mover kill does not remove it. On slow WAN paths these movers fill pool.mover.http-tpc.connections.max, and new transfers wait for a connection.

Change

  • RemoteHttpDataTransferProtocol copies the body from entity.getContent() itself and does not close the stream when the copy fails.
  • RemoteHttpTransferClient#get aborts the GET request if the body receiver throws, so the connection is shut down instead of being drained or reused. This also covers the per-transfer client used with X.509 delegation (closed only after get returns) and the WebDAV door when it proxies a pull.

Tests

  • RemoteHttpTransferClientTest: a local HTTP server announces 1 MB and sends 17 bytes; when the receiver fails or is interrupted the request is aborted; a complete body is not aborted.
  • RemoteHttpDataTransferProtocolTest: the whole body is copied; on a write or read failure the body is neither drained nor closed.
  • Reverting only the client change makes the two abort tests fail.
  • mvn -pl modules/dcache install: 1304 tests, 0 failures.

Not covered

If the remote server sends nothing at all, cancelling the mover still waits for the next data or the socket timeout before the request is aborted; there is no cancel hook in MoverProtocol other than the interrupt. The reported symptom, reading the rest of the body to the end, is fixed.

Backport

11.2 has no org.dcache.http.tpc package (the GET is done in RemoteHttpDataTransferProtocol), so the change will not cherry-pick as is; the same two steps apply there.

🤖 Generated with Claude Code

Motivation:
The remote-HTTP mover copies the GET response body with
HttpEntity#writeTo.  If the copy fails, for example because the mover
was cancelled (FTS "client went away", TransferManager timeout, mover
kill) and the write to the replica throws ClosedByInterruptException,
writeTo closes the content stream, and closing it reads the rest of
the body from the remote server.  This blocking read is not stopped
by the interrupt.  The mover stays in CANCELED state until the whole
file has arrived, holds an HTTP-TPC connection slot, and cannot be
killed.  On a slow WAN path these movers fill the connection pool and
new transfers wait for a connection.

Modification:
The mover copies the body from the entity's content stream itself and
does not close the stream if the copy fails.

RemoteHttpTransferClient#get aborts the GET request if the body
receiver throws, so the connection is shut down instead of being read
to the end or reused.  This also covers the per-transfer client used
with X.509 delegation, which is closed only after get returns, and
the WebDAV door when it proxies a pull.

Result:
A cancelled HTTP-TPC pull ends promptly and releases its connection.

Target: master, 12.0, 11.2
Require-book: no
Require-notes: yes
Fixes: dCache#8301
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Geonmo Ryu <geonmo@kisti.re.kr>
geonmo added a commit to geonmo/dcache-gsdc that referenced this pull request Nov 26, 2026
…dCache/dcache#8327)

Backport of dCache/dcache#8327 (fixes dCache/dcache#8301) to 11.2: a
cancelled HTTP-TPC pull no longer reads the rest of the remote body and
releases its connection slot. The change is in dcache-core, which is
already in container/overlay.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X3vgU2Uiah5GhGtrhNt391
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.

pool: cancelled HTTP-TPC pull keeps draining the remote response body and holds an http-tpc connection slot

1 participant