Skip to content

More explicitly drain the leftover bytes in buffer for the POST request in HTTPHander#81561

Closed
al13n321 wants to merge 5 commits intomasterfrom
keepa
Closed

More explicitly drain the leftover bytes in buffer for the POST request in HTTPHander#81561
al13n321 wants to merge 5 commits intomasterfrom
keepa

Conversation

@al13n321
Copy link
Member

@al13n321 al13n321 commented Jun 9, 2025

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fixed rare HTTP errors (Invalid HTTP version string: /?query=I) after INSERT using ArrowStream format, HTTP chunked encoding, and connection keep-alive.

Like #81461 , but with a simpler test and more reliable drain condition.

@clickhouse-gh
Copy link
Contributor

clickhouse-gh bot commented Jun 9, 2025

Workflow [PR], commit [a629959]

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 9, 2025
@vdimir vdimir self-assigned this Jun 10, 2025
{
auto hex_string = hexString(remaining.data(), remaining.size());
#if defined(DEBUG_OR_SANITIZER_BUILD)
throw Exception(ErrorCodes::LOGICAL_ERROR,
Copy link
Member

Choose a reason for hiding this comment

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

Won't the test throw this logical error then?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the test, the remaining bytes are the chunked encoding footer, not logical payload bytes. The HTTPChunkedReadBuffer will eat those bytes from its underlying ReadBuffer, but won't output any more bytes to higher-level ReadBuffer-s such as in_post_maybe_compressed.

throw Exception(ErrorCodes::LOGICAL_ERROR,
"There is still some data in the buffer: {}", hex_string);
#else
LOG_WARNING(log, "There is still some data in the buffer: {}", hex_string);
Copy link
Member

@cwurm cwurm Jun 10, 2025

Choose a reason for hiding this comment

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

This is printing huge strings for me with the test code in #81461.

This is just a fraction:

2025.06.10 10:10:48.586380 [ 1054220 ] {9a5f038d-8aa4-40fa-ae23-e60cfba0f6dc} <Warning> DynamicQueryHandler: There is still some data in the buffer: 3765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497a513765497

@CheSema CheSema mentioned this pull request Jun 10, 2025
1 task
if (!has_external_data && request.isStreamBounded() && response.getKeepAlive())
{
String remaining;
readStringUntilEOF(remaining, *in_post_maybe_compressed);
Copy link
Member

Choose a reason for hiding this comment

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

I think it is wrong to read data here, we do not know how much data there. We do not know why it is here.
It could be that we spend servers and clients resources just to drop the data.

This is my version:
#81595

@al13n321 al13n321 closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants