Skip to content

Report execution errors in clickhouse-local --ignore-error and align the exit code of clickhouse-client with it - #119572

Merged
alexey-milovidov merged 10 commits into
masterfrom
cursor/local-ignore-error-report-execution-errors-87fd
Sep 28, 2026
Merged

alexey-milovidov merged 10 commits into
masterfrom
cursor/local-ignore-error-report-execution-errors-87fd

Conversation

@yakov-olkhovskiy

@yakov-olkhovskiy yakov-olkhovskiy commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Closes: #119529
Related: #105480
Related: #106523

clickhouse local --ignore-error printed nothing at all for a statement that failed at execution — no message, no exception code — and exited with a success code, so a broken multi-statement script was indistinguishable from a working one:

$ clickhouse local --ignore-error --query "SELECT throwIf(1); SELECT 'still runs';"
still runs
$ echo $?
0

LocalServer::processError opened with if (ignore_error) return;, so neither the interactive print nor the non-interactive rethrow ran. Client::processError has no such gate, which is why clickhouse-client --ignore-error reported the same failure all along. Parse errors survived even in clickhouse-local, because those are printed by ClientBase::parseQuery and never reach processError — only execution errors vanished. The gate dates back to the clickhouse-local interactive-mode work in 615dbd4 (2021-09-05), which replaced an even broader if (!is_interactive) return;.

--ignore-error asks to carry on with the next statement, not to hide what went wrong, so the exception is now reported instead of rethrown — rethrowing it would end the run. The report follows what Client::processError already does, including the (query: ...) line that identifies the failing statement in a batch. The interactive branch becomes reachable as well: ignore_error is set for delayed_interactive too, so an interactive session silently swallowed its errors whenever --ignore-error was passed. ClientEmbedded::processError is a copy of the same function and had the same early return, so the embedded client is fixed along with it.

The exit code

Client::main returned the code of the exception left behind by the last statement of the batch. Per-statement state is reset at the top of processParsedSingleQuery, so that was the code of whichever error the final statement happened to hit and nothing else — the same batch exited with a failure or a success depending only on where in it the failing statement sat:

$ clickhouse-client --ignore-error --query "SELECT throwIf(1); SELECT 'ok';"; echo $?
0
$ clickhouse-client --ignore-error --query "SELECT 'ok'; SELECT throwIf(1);"; echo $?
139

clickhouse-local --ignore-error returned success in both. The client is aligned with it: the errors have been reported and the run elected to carry on, so it is not a failure. BuzzHouse keeps the error code, because it stops the run on an error anyway — the same exception it already makes in ClientBase::executeMultiQuery. This also generalizes what 04318_client_query_fuzzer_runs_ignore_parse_error already asserts, that a stale ignored exception must not decide the exit code.

Delayed-interactive runs

Client::processConfig read ignore-error only in its non-interactive branch, and --interactive together with --query or --queries-file takes the other one when stdin is a terminal. The option was dropped there, even though those queries are executed as a batch by runNonInteractive before the prompt is entered: the prelude stopped at its first failing statement and the code of that statement ended the run before runInteractive, so --ignore-error had no effect at all. clickhouse-local and the embedded client already load the option for delayed_interactive; the client now takes the same condition. Without --ignore-error such a run still ends at the reported exception, which is unchanged.

Tests

clickhouse-test fails a shell test on any non-empty stderr, so the three tests that drive clickhouse-local --ignore-error over a failing statement without redirecting stderr passed only because the error was swallowed; they discard the report now. The comment of 05042_local_system_database_deferred_populate_error said outright that --ignore-error "swallows the error text", which is no longer true.

Two tests are added. 05182_local_ignore_error_reports_execution_errors covers both programs with the failure placed before and after a working statement, so the exit code no longer depends on that position. 05183_client_delayed_interactive_ignore_error covers the delayed-interactive prelude for both --query and --queries-file; it needs a pty, because the option is only dropped when stdin is a terminal, so it is an expect test.

Verified against a local Release build. Both new tests fail on a binary built without the corresponding fix and pass with it. Every existing test that uses --ignore-error or --interactive passes, 26 in total, including 04650_geoparquet_wkt_empty_and_case and 03212_thousand_exceptions (formatting the 1000 reports it now emits costs about 5% of its runtime, with byte-identical stdout). As a regression check, all 317 local and client stateless tests were run twice with identical non-randomized settings, once with this branch and once with the unmodified master build: no test fails only with the change, and the one difference is the new test, which fails on the unmodified binary as intended. The failures common to both runs are the missing ZooKeeper, object storage and CI test configs of the local environment.

Changelog category (leave one):

  • Backward Incompatible Change

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

clickhouse-local --ignore-error now reports a statement that failed at execution instead of skipping it silently: previously it printed no message and no exception code, so a failing multi-statement script looked exactly like a passing one, while clickhouse-client --ignore-error reported every error all along. clickhouse-client also ignored the option entirely when it was combined with --interactive and --query/--queries-file on a terminal, and now applies it to those queries too. The exit code of clickhouse-client --ignore-error changes accordingly: it used to be the code of whichever error the last statement of the batch happened to hit, which made the result depend on the position of the failing statement rather than on the batch as a whole, and it is now a success code, matching what clickhouse-local --ignore-error has always returned. Scripts that relied on the old exit code to detect failures should drop --ignore-error so that the run stops and fails at the first error, or check the reported errors on stderr.

Open in Web Open in Cursor 

Workflow [PR]
Sync PR [sync-upstream/pr/119572]

Version info

  • Merged into: 26.10.1.879-master (included in 26.10 and later)

cursoragent and others added 4 commits September 12, 2026 01:27
`LocalServer::processError` returned early whenever `ignore_error` was set, so
`clickhouse-local --ignore-error` printed nothing at all for a statement that failed at
execution: no message and no exception code, which made a broken multi-statement script
indistinguishable from a working one. Parse errors were still reported, because those are
printed by `ClientBase::parseQuery` and never reach `processError`.

`--ignore-error` asks to carry on with the next statement, not to hide what went wrong, so
the exception is now reported instead of rethrown - rethrowing it would end the run.
`Client::processError` has always reported it this way, including the `(query: ...)` line
that identifies the failing statement in a batch.

The interactive branch is reached now as well: `ignore_error` is set for
`delayed_interactive` too, so the print of an interactive session was unreachable whenever
`--ignore-error` was passed.

Closes: #119529

Co-authored-by: yakov <[email protected]>
`Client::main` returned the code of the exception left behind by the last statement of the
batch. The per-statement state is reset in `processParsedSingleQuery`, so that was the code
of whichever error the final statement happened to hit and nothing else: the same batch
exited with a failure or a success depending only on the position of the failing statement
in it. `clickhouse-local --ignore-error` returned success in every one of those cases.

Align the client with it: `--ignore-error` has already reported every failed statement and
elected to carry on, so the run is not a failure. BuzzHouse keeps the error code, because
it stops the run on an error anyway - the same exception it already makes in
`ClientBase::executeMultiQuery`.

Co-authored-by: yakov <[email protected]>
`clickhouse-test` fails a shell test on any non-empty stderr, so the three tests that run
`clickhouse-local --ignore-error` over a failing statement without redirecting stderr
passed only because the error was swallowed. They discard the report now; the comment of
05042 said outright that the error text is swallowed, which is no longer the case.

The new test covers both programs, with the failure placed before and after a working
statement, so the exit code no longer depends on that position.

Co-authored-by: yakov <[email protected]>
Neither page said what `--ignore-error` does with the error itself or with the exit code,
and the client had no entry for it at all.

Co-authored-by: yakov <[email protected]>
@mintlify

mintlify Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Sep 12, 2026, 1:57 AM

@clickhouse-gh

clickhouse-gh Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [691aaf8]

Summary: ✅


AI Review

Summary

This PR makes --ignore-error consistent across clickhouse-local and clickhouse-client: execution errors are now reported instead of being silently swallowed in clickhouse-local, delayed-interactive client runs honor the option for their prelude batch, and the client no longer returns a failure code just because the last ignored statement happened to fail. After reviewing the current diff, the touched control flow in Client::main / ClientBase, the added tests, and the prior inline threads, I did not find any new actionable correctness or compatibility issues.

Missing context / blind spots
  • ⚠️ I did not run the changed tests locally. The PR’s attached CI report currently shows only the Build profile diff job, so there is no functional CI evidence here beyond the new regression tests added in the patch itself.
Final Verdict

✅ No new findings.

LLVM Coverage Report

Measured on commit 691aaf8.

Metric Baseline Current Δ
Lines 88.00% 88.00% +0.00%
Functions 91.80% 91.70% -0.10%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 24/31 (77.42%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Sep 12, 2026
`ClientEmbedded::processError` is a copy of `LocalServer::processError` and had the same
early return, so the embedded client swallowed execution errors under `--ignore-error` too.
Its exit code already matches `clickhouse-local`: `ClientEmbedded::run` returns zero unless
an exception propagates out of it.

Co-authored-by: yakov <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-cli clickhouse-client (interactive CLI) and client library. label Sep 12, 2026
The test harness runs the client with `--send_logs_level=warning`, so the server log of the
failing query reaches the client's stderr and the error name appears there a second time.
Silence the forwarded log, the way other tests that read stderr do.

Co-authored-by: yakov <[email protected]>
Comment thread programs/client/Client.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 691aaf830 with master 5e2608b5b (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

9 translation units recompiled, 30 s compile time in total, 9 of them have a recent master baseline.

Job report

@yakov-olkhovskiy
yakov-olkhovskiy marked this pull request as ready for review September 12, 2026 10:47
cursoragent and others added 2 commits September 12, 2026 13:06
`Client::processConfig` read `ignore-error` only in its non-interactive branch, and a
delayed-interactive run on a terminal (`--interactive` together with `--query` or
`--queries-file`) takes the other one. The option was dropped there, even though the given
queries are executed as a batch by `runNonInteractive` before the prompt is entered: the
prelude stopped at its first failing statement and `Client::main` returned the code of that
statement, ending the run before `runInteractive`.

`clickhouse-local` and the embedded client already load the option for
`delayed_interactive`; take the same condition.

The reported exception still ends such a run when `--ignore-error` is not given, which is
unchanged and outside of the option's contract.

Co-authored-by: yakov <[email protected]>
The option is only dropped when stdin is a terminal, because that is what makes
`is_interactive` true for a delayed-interactive run, so the test needs a pty. Both spellings
of the prelude are covered, `--query` and `--queries-file`.

Co-authored-by: yakov <[email protected]>
Comment thread programs/client/Client.cpp Resolved
@ClickHouse ClickHouse deleted a comment from CLAassistant Sep 13, 2026
cursoragent and others added 2 commits September 21, 2026 14:53
`ignore_error` does not say who asked for it. Besides the user's `--ignore-error`,
`Client::processOptions` turns it on for `--query-fuzzer-runs`, `--create-query-fuzzer-runs`
and BuzzHouse, so that they tolerate unparseable input, and the success exit code of an
ignored batch was handed to those modes as well.

The AST fuzzer reports an early stop through that exit code and through nothing else. When
`tryToReconnect` fails in `processWithASTFuzzer`, the step returns `false` with `have_error`
and the exception still set - it skips the reset that every completed step does - and
`runNonInteractive" just returns, so `Client::main` is the only place left to report it.
Granting it success ends a fuzzer run that lost the server after a handful of queries with
`Fuzzer exited with success` in `ast_fuzzer_job`, which reads `fuzzer_exit_code` 0 as OK.

Exclude the fuzzing modes the same way BuzzHouse already was, so only a user-supplied
`--ignore-error` gets the success exit.

Co-authored-by: yakov <[email protected]>
`--create-query-fuzzer-runs` is the mode that can be pinned down without taking the server
away mid-run: it turns `ignore_error` on but never enters the fuzz loop, which is what
discards the error of every step, so the exception of the last statement reaches
`Client::main` just like in a plain batch. The AST fuzzer's own early stop needs the server
to disappear, which does not belong in a stateless test, but it shares this root cause.

Co-authored-by: yakov <[email protected]>
@alexey-milovidov alexey-milovidov self-assigned this Sep 28, 2026
@ClickHouse ClickHouse deleted a comment from CLAassistant Sep 28, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 28, 2026
Merged via the queue into master with commit 7264abe Sep 28, 2026
349 of 350 checks passed
@alexey-milovidov
alexey-milovidov deleted the cursor/local-ignore-error-report-execution-errors-87fd branch September 28, 2026 04:27
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 28, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@yakov-olkhovskiy @alexey-milovidov — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

alexey-milovidov added a commit that referenced this pull request Oct 1, 2026
…he Join mutation tests

Since #119572 (#119572), `clickhouse-local --ignore-error`
reports execution errors on stderr, so the fail-point errors of the five Join mutation tests made
`Fast test` red ("having stderror"). Redirect stderr of those runs to a file and print the count of
`FAULT_INJECTED` errors, which also proves the injected failures happened.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=119196&sha=b253202e872a1f42851bbb312007c0e8e33040ae&name_0=PR&name_1=Fast%20test
PR: #119196

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
george-larionov added a commit that referenced this pull request Oct 29, 2026
26.9 `clickhouse-local` does not print errors under `--ignore-error` (changed in #119572), so run each query separately.

#128064

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim pushed a commit that referenced this pull request Nov 3, 2026
On this release branch `clickhouse-local --ignore-error` drops the exception of
a failed statement without printing it (`LocalServer::processError` returns
early). Printing it came with #119572, which is in 26.10 and later only. The
four failed updates still happen, but nothing reached stderr, so the test
printed 0 instead of 4. With `--send_logs_level=error` each failed query is
logged once by `executeQuery`, which restores the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim pushed a commit that referenced this pull request Nov 3, 2026
On this release branch `clickhouse-local --ignore-error` drops the exception of
a failed statement without printing it (`LocalServer::processError` returns
early). Printing it came with #119572, which is in 26.10 and later only. The
four failed updates still happen, but nothing reached stderr, so the test
printed 0 instead of 4. With `--send_logs_level=error` each failed query is
logged once by `executeQuery`, which restores the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ec6408d)
PedroTadim pushed a commit that referenced this pull request Nov 3, 2026
On this release branch `clickhouse-local --ignore-error` drops the exception of
a failed statement without printing it (`LocalServer::processError` returns
early). Printing it came with #119572, which is in 26.10 and later only. The
four failed updates still happen, but nothing reached stderr, so the test
printed 0 instead of 4. With `--send_logs_level=error` each failed query is
logged once by `executeQuery`, which restores the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ec6408d)
leshikus pushed a commit that referenced this pull request Nov 13, 2026
On this release branch `clickhouse-local --ignore-error` drops the exception of
a failed statement without printing it (`LocalServer::processError` returns
early). Printing it came with #119572, which is in 26.10 and later only. The
four failed updates still happen, but nothing reached stderr, so the test
printed 0 instead of 4. With `--send_logs_level=error` each failed query is
logged once by `executeQuery`, which restores the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
On this release branch `clickhouse-local --ignore-error` drops the exception of
a failed statement without printing it (`LocalServer::processError` returns
early). Printing it came with #119572, which is in 26.10 and later only. The
four failed updates still happen, but nothing reached stderr, so the test
printed 0 instead of 4. With `--send_logs_level=error` each failed query is
logged once by `executeQuery`, which restores the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ec6408d)
leshikus pushed a commit that referenced this pull request Nov 13, 2026
26.9 `clickhouse-local` does not print errors under `--ignore-error` (changed in #119572), so run each query separately.

#128064

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
On this release branch `clickhouse-local --ignore-error` drops the exception of
a failed statement without printing it (`LocalServer::processError` returns
early). Printing it came with #119572, which is in 26.10 and later only. The
four failed updates still happen, but nothing reached stderr, so the test
printed 0 instead of 4. With `--send_logs_level=error` each failed query is
logged once by `executeQuery`, which restores the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ec6408d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-cli clickhouse-client (interactive CLI) and client library. pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clickhouse local --ignore-error silently swallows execution errors: no message, exit code 0 — clickhouse-client prints them

5 participants