Repository navigation
Pass --allow_repeated_settings when collecting server stacktraces - #112845
Conversation
get_stacktraces_from_clickhouse builds a clickhouse-client command line from get_additional_client_options, which deliberately concatenates the CLICKHOUSE_CLIENT_OPT copy of --client-option with --client-option itself so that user-supplied values, coming last, win over the randomized settings. Any setting given both ways therefore appears twice on the command line. That is harmless while a test is running: add_effective_settings appends --allow_repeated_settings to the environment for the duration of the test. But remove_settings_from_env resets CLICKHOUSE_CLIENT_OPT to the flagless startup snapshot in a finally block after every test, and this collector runs precisely outside a test: from the per-test timeout handler and from the end-of-run hung check. Without the flag clickhouse-client exits 36 with "Bad arguments: option '--max_untracked_memory' cannot be specified more than once", so the hung-check report loses the system.stack_trace dump entirely. Add the flag where the command line is assembled, matching what add_effective_settings already does for the ordinary test path. All three query branches share the single settings_str, so one line covers them. Related: ClickHouse#109368
Comment text only. The two comment blocks added by the previous commit named functions, options and a log excerpt as bare text; `.claude/CLAUDE.md` requires literal names from ClickHouse SQL, classes and functions, and literal excerpts from log messages to be wrapped in inline code blocks. Names are written as `f`, not `f()`, as the same file requires. The comment in `tests/clickhouse-test` also said this collector "runs outside" a test. That is right for the end-of-run hung check, but `print_sql_stacktraces` is also reached from the per-test SIGALRM `timeout_handler`, which is armed around both `run` and `process_result`, so the environment may or may not carry `--allow_repeated_settings` at that moment. The comment now says the flag is added while a test runs and names both call sites. The fix is correct in either case because the flag is consumed in the argv pre-scan and is not forwarded to `boost::program_options`, so a second copy is idempotent. No behavioural change: stripping comments from both files before and after this commit yields byte-identical token streams, and `ast.dump` of each file is unchanged.
Internal second-model review (click to expand)Two review rounds, each an independent cold read of the resulting code followed by a separate Round 1 (2 nits, both fixed)
The round-1 fix was comment text only. Semantic equivalence was proved two ways rather than by Round 2 (clean)Both passes returned zero findings. Re-verified independently against the current 💡 💡 The multitoken registration the flag switches on absorbs only tokens that do not begin with 💡 The new test fails closed. Before the change
Session id: cron:clickhouse-review-slot-11:20260801-012000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260801-010002 |
|
cc @leshikus, could you review this? get_stacktraces_from_clickhouse assembles its client command line from get_additional_client_options, which deliberately concatenates the CLICKHOUSE_CLIENT_OPT copy of --client-option with --client-option itself, so any setting passed both ways appears twice and the client exits 36 before querying anything; the flag that tolerates repeats is only in the environment while a test runs, so the hung check loses its system.stack_trace dump. |
|
Workflow [PR], commit [59e42f4] Summary: ✅ AI ReviewSummaryThis PR fixes the hung-check and timeout stacktrace collector by always passing Final Verdict✅ No findings. |
CI finish ledger - 59e42f4Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260803-180000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
get_stacktraces_from_clickhouseintests/clickhouse-testbuilds aclickhouse-clientcommandline that can carry the same setting twice, and then dies before querying anything:
The duplication is intended.
get_additional_client_optionsconcatenates theCLICKHOUSE_CLIENT_OPTcopy of--client-optionwith--client-optionitself, so thatuser-supplied values come last and win; that is the documented last-occurrence-wins override.
add_effective_settingsmakes it safe by appending--allow_repeated_settingsto the environmentwhile a test runs, but
remove_settings_from_envresets the variable to the flagless startupsnapshot in a
finallyblock after every test. This collector is reached from the end-of-run hungcheck and from the per-test timeout handler, where the flag may not be set, so it assembles the
command with the duplicates and without the flag, and
clickhouse-clientexits 36.The consequence is a diagnostics loss: a hung-check report loses its
system.stack_tracedumpentirely, which is the only view that maps a stuck thread to the query it was running. The
Hung check failedverdict itself is decided elsewhere, so no CI result changes. It has beenobserved on
masteras well as on pull requests.This adds the flag where the command line is assembled, matching what
add_effective_settingsalready does for the ordinary test path. All three query branches share the single
settings_str,so one line covers them.
An observed failure:
Stress test (arm_tsan)on #109368.Validation: driving the real function against a live server returns 0 bytes with
exit status 36before the change and a 332 KB dump containing
thread_nameafter it. The new test inci/tests/test_print_stacktraces.pyasserts both that the assembled options really are duplicatedand that a dump comes back; reverting the one-line change reddens it with the message above.
Related: #109368
Version info
26.8.1.871(included in26.8and later)