Skip to content

[v0.11.0] Do not fail closing a partly read response that the server ended early (backport #3217) - #3234

Merged
chernser merged 3 commits into
v0.11.0from
polyglot/backport-v0.11.0-partly-read-response-close
Oct 21, 2026
Merged

chernser merged 3 commits into
v0.11.0from
polyglot/backport-v0.11.0-partly-read-response-close

Conversation

@polyglotAI-bot

@polyglotAI-bot polyglotAI-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Backports #3217 from main to v0.11.0, as requested by @chernser in #3231 (comment):

@polyglotAI-bot I'm a maintainer and asking you do the PR to v0.11.0 for me I'll review

Issue: #3231 (a closing keyword has no effect on a PR into a non-default branch, so close the issue manually after merge).

Cherry-picked PR

PR Merge commit on main Change Backport commit
#3217 848b3116b ResultSet#close() / QueryResponse#close() do not fail when the server ended a partly read response early (#3203) 536f9842c (clean)

Command: git cherry-pick -x -m 1 848b3116b. The commit keeps its original author and records its source commit.

Conflicts

None. The code and test changes are identical to the diff of #3217 on main, hunk by hunk. Only the blob index hashes are different.

Release notes (changed in review)

As requested in review, the release note of #3217 is in history/0_11_0_release/CHANGELOG.md (end of ## Bug Fixes), with the same text. history/latest/3203.md is removed from this PR, because v0.11.0 has no history/latest/ directory. Commit c6d853990.

Test

Done in a devbox (JDK 17 + JDK 8 toolchain, ClickHouse server 26.9.1):

  • mvn -B -pl client-v2,jdbc-v2 -am -DskipTests -Dmaven.javadoc.skip=true install: BUILD SUCCESS.
  • jdbc-v2 ResultSetImplTest (integration): 20 run, 0 failures. This includes the 2 new testCloseNotFullyReadResultSet cases.
  • client-v2 HttpTransportTests (integration): 96 run, 69 pass. The 3 new testClosingNotFullyReadResponse cases pass.
  • The bug is present on v0.11.0: with only HttpAPIClientHelper.java reverted to v0.11.0, the 3 new testClosingNotFullyReadResponse cases fail.
  • The other 27 HttpTransportTests failures are the same with and without this change. They are environment failures: the tests connect to the hardcoded localhost:8123 / localhost:8443, which are not reachable in this environment (the server has a different host name), and testServerErrorHandling expects error code 636 where this server returns 400. CI runs them against a local server.

This PR adds no tests, docs or version bump other than those in #3217, and the changelog entry above.

Checklist

🤖 Generated with Claude Code


Note

Medium Risk
Changes HTTP response teardown for failed mid-stream queries; behavior is narrowed (swallow close errors only when a body stream was opened) but affects connection reuse and error surfacing for all HTTP users.

Overview
Backports the fix for closing partly read HTTP query results when ClickHouse ends the response body early (e.g. query fails after rows were already streamed). Closing used to trigger Apache HttpClient’s body drain and could surface ConnectionClosedException / “Premature end of chunk coded message body” on QueryResponse#close(), ResultSet#close(), or reader close even though the real failure should appear while reading.

HTTP transport wraps the response body in ResponseBodyInputStream and treats ConnectionClosedException on close as DEBUG-only when a data stream was opened; errors while reading are unchanged. If the body was never opened (Client#execute / executeUpdate), close still propagates the failure so commands without a result set are not silently ignored.

Adds integration tests for client-v2 (several compression modes) and jdbc-v2 (RowBinaryWithNamesAndTypes, JSONEachRow), plus a v0.11.0 changelog entry for #3203.

Reviewed by Cursor Bugbot for commit c6d8539. Bugbot is set up for automated code reviews on this repo. Configure here.

…y-read-response

[client-v2, jdbc-v2] Do not fail closing a partly read response that the server ended early

(cherry picked from commit 848b311)
@chernser

Copy link
Copy Markdown
Contributor

@polyglotAI-bot sync from v0.11.0 - there is fix for build

@chernser chernser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sync with v0.11.0 to fix the CI build

@polyglotAI-bot

Copy link
Copy Markdown
Collaborator Author

@chernser Done. I merged v0.11.0 (fd98bda, #3236) into this branch: merge commit d60c9af, no conflicts.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Triage

Category: bugfix • Risk: medium

Summary
Maintainer-requested backport of #3217 from main to the v0.11.0 release branch (asked by @chernser in #3231). It fixes #3203: closing a partly read query response (QueryResponse#close(), ResultSet#close(), reader close) could throw ConnectionClosedException / "Premature end of chunk coded message body" when the server ended the response body early after a mid-stream query failure. The sole source change is in client-v2's HttpAPIClientHelper: TransportResponseImpl#close() catches ConnectionClosedException and logs it at DEBUG — but only when a data stream was created; otherwise it still propagates so Client#execute/executeUpdate failures are not silently swallowed. A new ResponseBodyInputStream (FilterInputStream) applies the same logic on stream close. Read-path errors are unchanged. The backport is reported as conflict-free and hunk-identical to #3217, with the release note moved into history/0_11_0_release/CHANGELOG.md. Integration tests are added for client-v2 (3 compression combinations) and jdbc-v2 (2 formats).

What this impacts

  • client-v2 HTTP transport (HttpAPIClientHelper): response/stream close behavior for all HTTP-based users — error surfacing on close and connection reuse after partially read responses.
  • jdbc-v2 indirectly via ResultSet#close() behavior (tests only in this module).
  • v0.11.0 release branch changelog.

Concerns

  • Medium rule fired: behavioral change in a hot-path module (client-v2) — error-on-close semantics change for every HTTP response; a swallowed ConnectionClosedException is the trade-off, mitigated by the dataStreamCreated guard and new regression tests.
  • Backport targets the v0.11.0 release branch, so correctness of the cherry-pick matters for the next patch release; author reports a clean cherry-pick (-x -m 1 848b3116b) identical to the already-merged [client-v2, jdbc-v2] Do not fail closing a partly read response that the server ended early #3217.
  • CI check status could not be fetched during triage; verify required checks are green before merge.

Required reviewer action

@chernser chernser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add the bug fix entry to history/0_11_0_release/CHANGELOG.md, as
requested in review. Remove history/latest/3203.md: the entry is now
in the release changelog, and v0.11.0 has no history/latest/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polyglotAI-bot

Copy link
Copy Markdown
Collaborator Author

@chernser Done in c6d8539.

The code and test changes are not changed. CI runs again on the new head.

@chernser
chernser merged commit 5ded4aa into v0.11.0 Oct 21, 2026
17 of 20 checks passed
@chernser
chernser deleted the polyglot/backport-v0.11.0-partly-read-response-close branch October 21, 2026 06:56
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