Repository navigation
Report failed HTTP requests in 00265 instead of dropping the evidence - #112112
PedroTadim merged 2 commits into
Conversation
Every one of the 13 invocations in 00265_http_content_type_format_timezone.sh
had the shape
${CLICKHOUSE_CURL} -vsS ... 2>&1 | grep -e '< Content-Type' ... | sort
`2>&1` merges curl's diagnostics into the pipe, `grep` drops them, and the
pipeline's exit status is `grep`/`sort`'s rather than curl's. `CLICKHOUSE_CURL`
carries no `--fail` and stateless `.sh` tests do not `set -e`, so a request that
never reached query execution produced missing header lines and nothing else:
measured against a listener that accepts and then resets the connection, the old
shape yields `pipeline_rc=0`, empty stdout and zero bytes of stderr.
That is not only cosmetic. `tests/clickhouse-test` already handles these runs:
`process_result_impl` checks `if stderr:` and returns `FailureReason.STDERR`
before the `RESULT_DIFF` branch, and `MESSAGES_TO_RETRY` already contains
`(total) memory limit exceeded`. With curl's stderr discarded the description
holds only a diff, so the existing machinery is blind to it. Of the three
occurrences recorded in the CI database over 30 days, the one that let the
server's error text through was classified correctly, while the two that
swallowed it produced an unattributable `result differs`.
Route every invocation through a local `curl_headers` helper that keeps curl's
`-v` diagnostics in a file, pipes that file into the unchanged
`grep`/`sed`/`sort` chains, and reports the diagnostic plus the response body on
stderr when the request never reached query execution. URLs, settings, filter
chains and the `.reference` file are untouched, and the test's stdout stays
byte-identical.
Three details are load-bearing, each covered by a mutation test:
* Classification is by the required `X-ClickHouse-Timezone` response header,
not by the exception code: one invocation deliberately runs a failing query
and the reference expects its timezone header, so keying on the exception
code would redden every healthy run. The match stays anchored because the
server lists that name in `Access-Control-Expose-Headers` on every response.
* The response body goes to a file: the test requests `Native` and
`RowBinary`, whose bodies contain NUL, and command substitution both
truncates at the NUL and makes bash warn on stderr.
* Both files are truncated before each request: on an early transport failure
curl never opens `-o`, so a previous request's body would otherwise be
reported as belonging to this one, and `(total) memory limit exceeded` is a
live `MESSAGES_TO_RETRY` entry, so a stale body could attribute a false
cause.
The nine sibling stateless tests that share this shape are deliberately left
alone: each needs its own error-path reasoning, and two of them count matches,
so for those a silently empty response is a false pass rather than a red. The
shared `CLICKHOUSE_CURL` definition is also untouched, since 319 tests use it
and several depend on error bodies, non-2xx responses or specific curl exit
codes.
Co-Authored-By: Claude Opus 5 <[email protected]>
…adline The guard added in the previous commit fires on a disjunction: a non-zero `curl` exit, OR a response with no `X-ClickHouse-Timezone` header. Its message and the comment above the helper described only the second condition, so the first one printed a false statement. Measured against a listener that emits complete, correct `200` headers including a real `X-ClickHouse-Timezone`, then a `Content-Length` larger than the body it actually sends, then a reset: `curl` exits 56 with the header present, so only the exit-status condition fires, and the report claimed the request never reached query execution when it demonstrably had. That shape is caught either way; only the wording was wrong. Reword the single unconditional `echo` to cover both conditions and keep `(curl exit $rc)`, which is what discriminates a header-missing response from a transport failure. Update the comment block to state both conditions. No logic change: the guard, the truncation, the body file, the anchored match and all 13 call sites are untouched, and the test's stdout stays byte-identical to `origin/master`'s (sha256 7611820edd3674d2..., which is also the `.reference` hash). The new headline was checked against `MESSAGES_TO_RETRY` in `tests/clickhouse-test`: it matches none of the 11 entries, so it cannot itself make a run retryable. Related: ClickHouse#111777 Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (2 rounds, click to expand)This change was reviewed by an independent model before publication, then re-reviewed after Round 1 - 1 major, 1 nit (same defect), 1 major disagreed❌ The failure headline described only one of the guard's two conditions. The guard fires on
Round 2 - cleanThe re-review of the fix round returned no findings. The round was verified to be 💡 Noted, not blocking. One comment line added by the first commit names Session id: cron:clickhouse-review-slot-10:20260727-133900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-46:20260727-123200 |
|
cc @CheSema — could you review this? It is a test-only change: all 13 invocations in |
|
Workflow [PR], commit [6acb367] Summary: ❌
AI ReviewSummaryThis PR rewrites Final Verdict✅ No findings. |
CI finish ledger — 6acb367Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Not PR-caused: this PR's diff is Session id: cron:our-pr-ci-monitor:20260728-023000 |
1856d0a
Related: #111777
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
00265_http_content_type_format_timezonediscards the evidence when one of its HTTPrequests fails, so a failed request is reported as a bare
result differswith no errortext anywhere.
Every one of its 13 invocations has the shape
2>&1merges curl's diagnostics into the pipe,grepdrops them, and the pipeline's exitstatus is
grep/sort's rather than curl's.CLICKHOUSE_CURLcarries no--fail(
tests/queries/shell_config.sh:156) and stateless.shtests do notset -e. Measuredagainst a listener that accepts and then resets the connection, the current shape yields
pipeline_rc=0, empty stdout and zero bytes of stderr: the failure leaves no trace atall, and the only symptom is that whole 3-line header groups are missing from the output.
Why that matters beyond cosmetics.
tests/clickhouse-testalready knows how to handlethese runs:
process_result_implchecksif stderr:and returnsFailureReason.STDERRbefore the
RESULT_DIFFbranch, andMESSAGES_TO_RETRYalready contains(total) memory limit exceeded. Because the test deleted curl's stderr, the descriptioncontains only a diff, so the existing retry machinery is blind to it. Of the three
occurrences of this failure recorded in the CI database over 30 days, the one that happened
to let the server's error text through was classified correctly and is retryable today,
while the two that swallowed it produced an unattributable
result differs. Same trigger,opposite outcomes, and the difference is entirely the discard.
What changed. A local
curl_headershelper writes curl's-vdiagnostics to a file andpipes that file into the existing
grep/sed/sortchains unchanged. When curl reports anon-zero exit status, or when the response carries no
X-ClickHouse-Timezoneheader (whichevery request here must answer with), it reports curl's own diagnostic and the response body
on stderr instead of letting
grepeat them. URLs, settings, filter chains and the.referencefile are untouched.Both conditions are needed and neither subsumes the other, which is why the message names
both: a server that refuses the request before parsing answers
200-style withcurlexit0and no timezone header, while a connection reset gives a non-zero curl exit.A response whose headers are complete but whose body is then truncated satisfies the header
condition and is caught by the exit status alone; that shape passes on
mastertoday andbecomes a loud failure here, which is intended: a request that did not complete should not
be reported as a success.
Three details are load-bearing and each is covered by a mutation test:
invocation deliberately runs a failing query (
intDivby zero) and the referenceexpects its
X-ClickHouse-Timezoneheader, so keying on the exception code wouldredden every healthy run. The reference has exactly 13
X-ClickHouse-Timezonelines for13 invocations, so requiring that header is universal here. The match must stay anchored
(
^< X-ClickHouse-Timezone:), because the server lists that name inAccess-Control-Expose-Headerson every response.Nativeand
RowBinary, whose bodies contain NUL; command substitution truncates at the NUL andmakes bash print
warning: command substitution: ignored null byte in input, which woulditself fail the test.
opens
-o, so a previous request's body would otherwise be reported as belonging to thisone. That is not cosmetic:
(total) memory limit exceededis a liveMESSAGES_TO_RETRYentry, so a stale body could attribute a false cause.
Scope. Nine sibling stateless tests share the same "run curl verbosely, then grep the
response header lines" shape and are deliberately left out of this PR: each needs its own
error-path reasoning (some of their lines legitimately expect no match, one greps non-2xx
responses on purpose, and two count matches, so for those a silently empty response is a
false pass rather than a red, which is worse than the failure fixed here). The shared
CLICKHOUSE_CURLdefinition intests/queries/shell_config.shis also deliberatelyuntouched: 319 tests use it and several depend on reading error bodies, non-2xx responses,
or specific curl exit codes.
Verification. Healthy requests emit exactly zero bytes of stderr (12 consecutive runs),
the test's stdout is byte-identical to
origin/master's output on the same binary(
sha256 7611820edd3674d2..., which is also the.referencehash), 50/50 randomized runspass, and six concurrent copies pass with no temporary-directory collisions. Reverting the
helper makes both real-world failure shapes silent again; dropping the header guard alone,
replacing the body file with command substitution, dropping the truncation, or leaving a
single invocation un-routed each re-break exactly one measured property.