Repository navigation
Fix misleading Code 210 and opaque failures in functional-test server setup - #108593
Algunenano merged 8 commits into
Conversation
The "Start ClickHouse Server" setup stage of functional/stress/upgrade jobs intermittently logged a misleading "Code: 210 ... Connection refused (localhost:9000) (NETWORK_ERROR)" and collapsed unrelated setup sub-failures into one opaque bucket. 1) ClickHouseProc.start() flushed system logs before the caller runs wait_ready(): the server has written its pid file but is not yet listening on the TCP port (pid file is written ~700ms before the listener binds), so "system flush logs" fails with Code 210. The result was discarded, so it never failed the job, but it polluted every setup log and made triage look like a startup crash. Remove it: the flush is a startup no-op (no tests have run), and the meaningful flushes remain in terminate() and start_light() (which flushes after its own wait_ready()). The offline save_system_metadata_files_from_remote_database_disk() is kept. 2) Setup failures and the minio restart status were only printed to stdout, never surfaced into the persisted Result (CIDB test_context_raw). Print a concise "SETUP FAILURE: <sub-step>" marker at each failure point (from_commands_run captures the closure's stdout into Result.info on failure), and persist the non-fatal minio log-table/restart failure via set_info even on the success path. Control flow is unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-6:20260626-102900 |
|
cc @maxknv @leshikus — could you review this CI setup fix? It (1) removes a premature |
|
Workflow [PR], commit [98b6015] Summary: ✅ AI ReviewSummaryThis PR moves the startup Final Verdict✅ No new findings on the current PR head. |
CI finish ledger — fabd03fCI fully finished (Finish Workflow + Mergeable Check passed). All functional/integration/build/style checks green; no test-level failures on this commit. Every red check below has an owner.
Session id: cron:our-pr-ci-monitor:20260626-180000 |
@groeneai This is not true. At least historically (not sure if that's still the case) log tables were not created until something was flushed, so if a test tried to access system.query_log for example before anything had written to it it would get an error about the table not existing. By flushing we make sure the tables always exists so individual tests don't have to deal with it. Please make sure you maintain the call to flush logs but do it after the server is ready and listening to queries. |
Addresses review feedback on the FT server-bring-up cleanup. The system-log flush is preserved (it pre-creates the system log tables, e.g. system.query_log, so individual tests can read them without a "table does not exist" error), but it now runs inside wait_ready() on the success path, i.e. once the server is ready and listening. The previous flush in start() ran while the server had written its pid file but had not yet bound the TCP port, so it raced the listener and logged a misleading Code 210 (Connection refused). The flush in start_light() is removed as redundant (it already calls wait_ready() first); terminate() keeps its end-of-job flush. create_minio_log_tables() now stores the concrete failure detail (the real clickminio restart status string) on self.minio_setup_error, and the functional test setup persists that concrete detail into the step Result.info (CIDB test_context_raw) instead of a generic "see status above" note, so a broken minio restart is queryable in CIDB even though it is non-fatal. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@Algunenano You're right, thanks for the correction. The flush is now kept and moved to after the server is ready and listening, not removed. Done in 50d901f:
Also addressed the bot's inline note on the minio path: |
create_minio_log_tables() is non-fatal: the functional-test setup keeps going when it returns False (and bugfix-validation treats it the same). But the two `/mc admin config set` webhook calls used strict=True, so on a non-zero exit Shell.run raises RuntimeError (utils.py) before the `if not res:` branch could set minio_setup_error and return False. That turned a webhook-config failure into a hard "Start ClickHouse Server" failure (defeating the non-fatal guarantee this PR preserves) and still did not persist the reason for CIDB. Run every step non-strict in a (description, command) loop and, on the first failing step, record the concrete failing sub-step in minio_setup_error and return False. The caller persists that string via set_info, so a webhook-config failure now stays non-fatal and lands in test_context_raw naming the exact step instead of raising or collapsing into the opaque umbrella. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Completes the observability half of this PR for the last opaque setup sub-cause: stateful-data preparation. prepare_stateful_data() ran a large bash blob via Shell.check() and returned only a boolean, so when one of its dataset queries failed (intermittently on the slow msan bugfix-validation leg under shared-runner host load) the bugfix-validation re-prepare path could only report the generic "failed to re-prepare stateful data". The concrete failing sub-command and the ClickHouse client error never reached Result.info / CIDB test_context_raw, collapsing this sub-cause into the opaque "Cannot start clickhouse-server" umbrella. Now prepare_stateful_data() runs the blob via Shell.run (same bash executable, so `set -e`/`set -o pipefail` still apply) with a log file, an ERR trap that records which sub-command failed, and on a non-zero exit captures the log tail into self.stateful_setup_error. Both callers (the START stage and the bugfix-validation re-prepare leg) prefer that concrete reason over the generic message. Success semantics are unchanged (returncode == 0); on the success path no error is set. This is observability only: no retry/timeout band-aids are added (the blob is non-idempotent and the host-load flake is not locally reproducible). Making the real reason visible is the prerequisite for any later targeted reliability fix. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Follow-up commit 633f156: Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260629-171300 |
CI finish ledger — 633f156999f80e513b07e4334382a758e0a1ecCI fully finished (Finish Workflow + Mergeable Check passed). Bugfix validation, Stateless, builds and Style are green on this head. Every red check below has an owner.
Session id: cron:our-pr-ci-monitor:20260629-220000 |
The replica_num == 0 guard around _flush_system_logs() reads as 'flush only replica 0', but _flush_system_logs() already iterates every running replica (self.proc, self.proc_1, self.proc_2). The guard only prevents the recursive wait_ready(1/2) calls from re-running the fan-out. Comment-only change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Two observability completeness fixes for the bugfix-validation re-prepare path, so the persisted "Environment setup" row names what actually failed instead of collapsing into the generic "failed to re-prepare stateful data" bucket this PR is splitting. 1. functional_tests.py: split the prepare_stateful_data() / insert_system_zookeeper_config() boolean chain like the START stage already does. Previously a successful data prep followed by a failing insert_system_zookeeper_config() still reported "failed to re-prepare stateful data", pointing at the wrong operation. Now the zookeeper-config failure sets reprepare_error = "insert_system_zookeeper_config failed". 2. clickhouse_proc.py: include $BASH_COMMAND in the prepare_stateful_data ERR trap. The trap recorded $LINENO + exit code but not the command itself, so stateful_setup_error still required reconstructing the generated shell blob to find the failing query. It now carries the command text. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Resolve conflict in ci/jobs/scripts/clickhouse_proc.py: master refactored the clickminio restart into a robust retried _force_restart_minio() fallback (ClickHouse#108821 env-setup flake). Keep that fallback and re-apply this branch's observability: record self.minio_setup_error when both the clean and manual restarts fail, so the reason still reaches the setup Result / CIDB. ci/jobs/functional_tests.py auto-merged cleanly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
On the terminal non-fatal restart path the clean mc admin service restart status/timeout and the manual _force_restart_minio failure reason were only printed, not carried into minio_setup_error. Because minio setup can still succeed overall, from_commands_run does not persist those prints into Result.info, so a restart failure collapsed back into a generic CIDB bucket. _force_restart_minio now returns None on success or a concrete reason string, and _restart_minio_to_apply_config records the clean-restart status and the manual-restart reason into minio_setup_error before returning False. Success semantics are unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Reliability follow-up to the observability work here: the msan stateful re-prepare host-OOM (Code 241 on |
The bugfix-validation job swaps in each sanitizer binary and re-runs prepare_stateful_data(). On the msan leg the server's baseline RSS already sits near max_server_memory_usage (the host RSS ceiling), so the re-prepare INSERTs running with max_insert_threads=16 push the total memory tracker over the limit and fail with Code: 241. DB::Exception: (total) memory limit exceeded: would use 19.53 GiB ..., current RSS: 53.62 GiB, maximum: 53.62 GiB ... (query: INSERT INTO test.hits_s3 SELECT * FROM test.hits SETTINGS ... max_insert_threads=16) This surfaces as an 'Environment setup (*_msan)' ERROR (the concrete reason is now visible thanks to the observability plumbing in ClickHouse#108593). Lower max_insert_threads to 4 when the binary under test is a sanitizer build (asan/tsan/msan/ubsan), keeping 16 for non-sanitizer builds. The exact same data is loaded; only the transient per-insert working set shrinks. The ERROR-on-failed-reprepare guard is unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…se-server-setup-flush-noise Fix misleading Code 210 and opaque failures in functional-test server setup
The bugfix-validation job swaps in each sanitizer binary and re-runs prepare_stateful_data(). On the msan leg the server's baseline RSS already sits near max_server_memory_usage (the host RSS ceiling), so the re-prepare INSERTs running with max_insert_threads=16 push the total memory tracker over the limit and fail with Code: 241. DB::Exception: (total) memory limit exceeded: would use 19.53 GiB ..., current RSS: 53.62 GiB, maximum: 53.62 GiB ... (query: INSERT INTO test.hits_s3 SELECT * FROM test.hits SETTINGS ... max_insert_threads=16) This surfaces as an 'Environment setup (*_msan)' ERROR (the concrete reason is now visible thanks to the observability plumbing in ClickHouse#108593). Lower max_insert_threads to 4 when the binary under test is a sanitizer build (asan/tsan/msan/ubsan), keeping 16 for non-sanitizer builds. The exact same data is loaded; only the transient per-insert working set shrinks. The ERROR-on-failed-reprepare guard is unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
De-noise and de-opaque the "Start ClickHouse Server" functional-test setup stage. Two independent issues in
ci/jobs/scripts/clickhouse_proc.py/ci/jobs/functional_tests.py:1. Misleading
Code: 210 ... Connection refusedflush noise (correctness).ClickHouseProc.start()ended withself._flush_system_logs(). Callers runwait_ready()afterstart()(e.g.functional_tests.py:CH.start()thenCH.wait_ready()), so at that point the server has already written its pid file but is not yet listening on the TCP port. The pid file is written ~700 ms before the listener binds, soclickhouse-client --query "system flush logs"fails withCode: 210. DB::NetException: Connection refused (localhost:9000). (NETWORK_ERROR). The return value was discarded, so it never failed the job, but it polluted every setup log and made triage look like a startup crash.The flush itself is kept: it pre-creates the system log tables (
system.query_log, etc.), which are otherwise not materialized until the first flush, so individual tests can read them without hitting a "table does not exist" error. It is simply moved to where the server is actually ready and listening: intowait_ready()'s success path (the point at which the server has answeredselect 1). This keeps the table pre-creation while avoiding the Code 210 race against the TCP listener. The now-redundant explicit flush instart_light()is removed (it already callswait_ready()first);terminate()keeps its end-of-job flush. The adjacentsave_system_metadata_files_from_remote_database_disk()is kept (it uses the offlineclickhouse diskstool, not a server connection).Verified with a live debug server: firing
system flush logsthe instant the pid file appears returnsCode: 210(the oldstart()placement); firing it afterselect 1succeeds (rc=0) andEXISTS TABLE system.query_loggoes from0(before) to1(after), confirming the post-wait_readyflush still pre-creates the system log tables.2. Opaque setup failures (observability).
When setup failed, the failing sub-step and the minio
mc admin service restartstatus were only printed to stdout and never reached the persistedResult.info(CIDBtest_context_raw), so unrelated sub-causes (server-not-ready, minio restart, kafka bring-up, stateful-data prep) all collapsed into one opaque "Cannot start clickhouse-server" bucket. This restructures the setup closure to print a conciseSETUP FAILURE: <sub-step>marker at each failure point (from_commands_runcaptures the closure's stdout intoResult.infoon failure). For the non-fatal minio log-table/restart failure,create_minio_log_tables()now carries the concrete reason (the realclickminiorestart status string) out viaself.minio_setup_error, and the setup persists that concrete detail into the stepResult.infoviaset_infoeven on the success path (it is otherwise only a report-page warning, invisible in CIDB). The bugfix-validation rebuild path's environment-setup error row is likewise annotated with the concrete sub-step that failed. Control flow is unchanged: minio remains non-fatal; stateful prep is still gated onhas_stateful_tests.Version info
26.7.1.358(included in26.7and later)