Skip to content

Backend: the zero-copy reader evicts the connection still borrowing the host buffer - #6356

Merged
shai-almog merged 1 commit into
masterfrom
backend-zero-copy-evict
Nov 30, 2026
Merged

shai-almog merged 1 commit into
masterfrom
backend-zero-copy-evict

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

BackendHttpIntegrationTest.bodilessStatusDoesNotDesyncTheConnection failed on CI with its first reply 400 duplicate Host header. A pipelined request had been parsed out of bytes that another connection's read wrote into the same per-host zero-copy buffer.

Until now, advance() privatised the buffer of a connection that stopped mid-request, but only when it could find that connection again by descriptor after the switch. With this change the reader evicts: before a zero-copy read, a different connection that is still borrowing the host's buffer is given its own copy first (VtHost.borrower, Conn.evictOtherBorrower). That holds whatever path switched the connections. It copies only when two connections actually overlap, and zero-copy reads stay on.

Tests:

  • BackendHttpIntegrationTest, run locally: 79 tests, 0 failures, 1 skipped.
  • A stress client against the translated PetServer: 4.07M pipelined requests with 6.6KB headers, 0 wrong replies.
  • Backend SpotBugs, PMD and Checkstyle are all at zero.

The race never reproduced locally, either before or after the fix. Neither run proves the fix, and this PR has no reproducing test.

🤖 Generated with Claude Code

…he host buffer

The read buffer is per host, and advance() privatised a connection that
stopped mid-request only if it could find it by descriptor afterwards. A
pipelined pair still came back 400 duplicate Host header on CI. Before a
zero-copy read, a different connection still borrowing the buffer now gets
its own copy, whatever path switched it out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shai-almog
shai-almog merged commit ae70698 into master Nov 30, 2026
12 of 17 checks passed
@shai-almog
shai-almog deleted the backend-zero-copy-evict branch November 30, 2026 06:49
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.

1 participant