Repository navigation
Reset client_exception when --ignore-error skips a parse failure - #106523
Conversation
When a query in a multi-query batch fails to parse, the local ClientBase::parseQuery on the is_interactive || ignore_error branch catches the parser exception, sets client_exception, and returns nullptr. Without ignore_error, analyzeMultiQueryText's outer try/catch takes over and the test-hint logic in the PARSING_EXCEPTION stage clears the exception when the failure was expected. With ignore_error true, the !parsed_query branch instead skipped past the offending query and returned CONTINUE_PARSING, but never reset client_exception or have_error. The pinned exception then surfaced as the process exit code in Client::main, even though the run had explicitly elected to ignore parse errors. This affects --query-fuzzer-runs, which auto-enables ignore_error in Client::processOptions: targeted-fuzzer runs over a corpus that includes any test with a parse-time clientError hint exit Code 36 BAD_ARGUMENTS for example, which reads as a CI failure even though the fuzzer behaved correctly. Reset have_error and client_exception when the loop elects to skip the failing query, so the skip is honest and the exit code reflects the rest of the run. PARSING_EXCEPTION already clears current_exception through the rethrow / TestHint path, so this only affects the ignore_error skip. Adds a stateless regression test exercising the clickhouse-client --query-fuzzer-runs <file with parse-time error> shape that the targeted AST fuzzer in CI uses. CI report (PR-only checks failing): https://s3.amazonaws.com/clickhouse-test-reports/PRs/105579/0b07d9f2e61d8742d1889c96d8530b37186594cd/ast_fuzzer_amd_debug_targeted/job.log Related: ClickHouse#105579
Pre-PR validation gate
Session id: cron:clickhouse-ci-task-worker:20260605-041200 |
|
cc @azat - could you review this? Small ClientBase fix that clears |
|
Workflow [PR], commit [d40ac24] Summary: ✅
AI ReviewSummaryThis PR resets the client error state when Final VerdictStatus: ✅ Approve |
The previous commit cleared have_error and client_exception when the ignore_error branch in `analyzeMultiQueryText` skipped past a parse failure. That covered the targeted-fuzzer red-check scenario, where the parse failure is the only error, but it left a gap reported in inline review on PR ClickHouse#106523: If a previous statement under `--ignore-error` produced a server error, `server_exception` and `error_code` were set and have not been reset. The loop continues; the next statement fails to parse and reaches the ignore_error skip; the skip clears `client_exception` and `have_error`, but `server_exception` and `error_code` remain pinned. `Client::main` prefers `server_exception` over `client_exception` for the exit code, so the process exits with the stale server error code even though `--ignore-error` had elected to continue past both failures. The `assert(have_error == (client_exception || server_exception))` debug-build invariant in `Client::processError` is also briefly false until the next executed query. Mirror the full per-query reset at the top of `processParsedSingleQuery` (have_error/error_code/client_exception/server_exception) so the skip leaves the same state a successful query would. Extend the regression test `04318_client_query_fuzzer_runs_ignore_parse_error` with the bot's two-statement scenario: a server-error statement followed by a parse-error statement under `--ignore-error`. Pre-fix: exit 60 (UNKNOWN_TABLE leaks). Post-fix: exit 0. Bot review: ClickHouse#106523 (comment) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (commit d40ac24, gap-closing iteration)
Bot review: Session id: cron:clickhouse-ci-task-worker:20260605-141700 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 8/8 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 4 line(s) · Uncovered code |
CI ledger — covered SHA: d40ac24CI fully finished and clean (Finish Workflow + Mergeable Check completed at 18:32:22Z, >20 min buffer; mergeStateStatus=CLEAN).
No PR-caused failures. CI fully green. Ball with reviewer (@azat). Session: cron:our-pr-ci-monitor:20260605-190000 |
When a query in a multi-query batch fails to parse, the local
ClientBase::parseQueryon theis_interactive || ignore_errorbranchcatches the parser exception, sets
client_exception, and returnsnullptr.Without
ignore_error,analyzeMultiQueryText's outer try/catch takesover and the test-hint logic in the
PARSING_EXCEPTIONstage clears theexception when the failure was expected.
With
ignore_error = true, the!parsed_querybranch instead skippedpast the offending query and returned
CONTINUE_PARSING, but nevercleared
client_exceptionorhave_error. The pinned exception thensurfaced as the process exit code in
Client::main, even though the runhad explicitly elected to ignore parse errors.
This affects
--query-fuzzer-runs, which auto-enablesignore_errorinClient::processOptions: a targeted-fuzzer run over any corpus thatcontains a parse-time
clientErrorhint (the test hintsBAD_ARGUMENTSor
SYNTAX_ERRORthrown inside parserparseImpl, e.g.Multiple primary keys are not allowed) exits with that error's code(
36forBAD_ARGUMENTS). The praktikaast_fuzzer_job.pyrunnertreats any
fuzzer_exit_codeoutside(0, 137, 143, 227)asERROR,so the job goes red even though the fuzzer behaved correctly.
This was discovered while triaging the two failing CI checks on
#105579 (
AST fuzzer (amd_debug, targeted)and theold_compatibilityvariant). The PRadds a new test that contains a
-- { clientError BAD_ARGUMENTS }hint on a parser-time throw; the targeted fuzzer fed exactly that
file to
clickhouse-client --query-fuzzer-runs=...and exited withCode 36.The fix clears
have_errorandclient_exceptionat theignore_errorskip inanalyzeMultiQueryText, so the skip is honestand the process exit code reflects the rest of the run.
PARSING_EXCEPTIONalready clearscurrent_exceptionthrough therethrow /
TestHintpath, so this only affects theignore_errorskip — no other behavior changes.
Adds a stateless regression test
04318_client_query_fuzzer_runs_ignore_parse_error.shthat runsclickhouse-client --query-fuzzer-runs=2 --create-query-fuzzer-runs=2 --queries-file <file>where
<file>ends with a query that throwsBAD_ARGUMENTSat parsetime. Pre-fix the script exits
36; post-fix it exits0. Verifiedlocally by reverting the fix, rebuilding, and observing the test fail
(
exit: 36vs referenceexit: 0), then rebuilding with the fix andseeing it pass 5/5.
Related: #105579
CI report (failing AST fuzzer checks): https://s3.amazonaws.com/clickhouse-test-reports/PRs/105579/0b07d9f2e61d8742d1889c96d8530b37186594cd/ast_fuzzer_amd_debug_targeted/job.log
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.6.1.441