Repository navigation
darwin fast test: attach full server stacktrace dumps as logs; fix lldb attach on macOS - #107173
Conversation
|
Workflow [PR], commit [f5dbada] Summary: ✅ AI ReviewSummaryThis PR moves Findings
Final Verdict
|
… fix lldb on macOS On a per-test timeout or the end-of-run hung check, `clickhouse-test` dumps server stacktraces. Two problems showed up in the macOS fast test: - The full `system.stack_trace` dump (over a thousand threads) and the lldb backtraces were inlined into the test description, flooding `job.log` (~31k lines for a single timeout) and the per-test report `info`. - `lldb --batch -p <pid>` failed to attach on the macOS runner and `exit 1`, and `shell_get_output` discarded the command output, so the log kept only `returned non-zero exit status 1` without the reason. Changes: - Write the full dumps to per-collector files (`sql_stacktraces.log`, `c_stacktraces.log`) and attach them to the report from `fast_test.py`; stdout keeps only a `trim_for_log` preview. The files are per collector, not per test, because the hung check has no single owning test. - Attach lldb as root on Darwin (the runner has passwordless sudo and root holds `task_for_pid` rights); `shutil.which` resolves the path since sudo resets `PATH`. Linux is unchanged. - Surface the merged stdout/stderr of a failed command in `shell_get_output`, bounded with `trim_for_log` so a command that prints many lines and only then exits non-zero (e.g. lldb dumping backtraces) cannot flood `job.log`. - Order the `system.stack_trace` dump `query_id <> '' DESC, thread_id DESC` so the wedged query's threads (and newest threads) come first. - Bound the inline timeout/cleanup diagnostic with `trim_for_log`.
a805117 to
53e9d06
Compare
… trim_for_log Address review feedback on the stacktrace reporting: - shell_get_output gains keep_output_on_error: lldb may exit non-zero yet still print backtraces (or an attach error) worth keeping. With the flag the caller receives that output, so print_c_stacktraces saves the full dump to c_stacktraces.log and prints only a trim_for_log preview — the same path as a successful run — instead of shell_get_output dumping it to stderr with nothing attached. The default path is unchanged for the other callers. - trim_for_log now newline-terminates its result, so callers no longer each re-add the trailing newline that splitlines() drops.
…ir as Path
- The stdout previews kept trim_for_log's default 10000-line limit, so a ~31k
line dump still put 10000 lines in job.log. Now that the full dump is
attached as a file, pass an explicit 100-line limit (the small-preview limit
already used elsewhere in this file) to print_c_stacktraces,
print_sql_stacktraces and the timeout/cleanup diagnostic. With the reordered
dump (query_id <> '' DESC) the wedged-query threads lead the preview.
- fast_test.py: temp_dir becomes a Path, so f"{temp_dir}/..." no longer
produces double slashes and the stacktrace-log paths join with the / operator.
- clickhouse-test: the per-collector log comment claimed appends cannot corrupt
across two simultaneous --jobs timeouts. O_APPEND only keeps a single write()
atomic and a large dump can span several writes, so two workers may
interleave; reword to say the per-block headers keep the result readable.
|
@tavplubix we have a discussion if |
|
We still need |
…g comments tavplubix pointed out that ordering server stacktraces newest-first via thread_id DESC does not make sense: thread_id is not monotonic (TIDs are reused after a thread exits) and GlobalThreadPool reuses threads, so the highest TID is not the last thread. Idle threads are also not always noise — a query may be waiting on a background operation. Drop the thread_id DESC part and keep only query_id <> '' DESC, which surfaces threads currently executing a query at the top of the trimmed stdout preview on a timeout. All other threads still follow and the full dump is attached as a log file, so nothing is dropped. Rewrite the comments to drop the refuted claims. Related: ClickHouse#107173
Revert the ORDER BY reordering of the server-stacktrace SQL queries so they match master exactly: query_id-first ordering only affected the trimmed stdout preview, and the full dump is attached as a log regardless, so it is not worth diverging from master. tavplubix also objected to the reasoning. The three queries are back to their pre-PR form: - replicated / shared catalog: ORDER BY host, thread_id - single node: no ORDER BY Related: ClickHouse#107173
The client-stacktrace path in the timeout kill handler printed the raw output of `get_stacktraces_from_lldb` directly. Because that helper is called with `keep_output_on_error=True`, it returns the full lldb output even on a non-zero exit (e.g. a later `detach`/`quit` fails after many frames were already printed), so the whole payload went straight into `job.log` unbounded. Wrap it in `trim_for_log`, matching the bounded error path in `shell_get_output`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…o darwin-test-diagnostics # Conflicts: # ci/jobs/fast_test.py
| # trimmed preview. Append with a per-block header so successive dumps stay | ||
| # separated; two --jobs workers timing out at once may still interleave (a | ||
| # large write is not atomic), but the headers keep the result readable. | ||
| SQL_STACKTRACES_LOG = "sql_stacktraces.log" |
There was a problem hiding this comment.
clickhouse-test is a shared runner, but this new side-file path is only wired into fast_test.py. The main functional-test command at ci/jobs/functional_tests.py:125 and the diagnostics replay at ci/jobs/functional_tests.py:1215 still run clickhouse-test --hung-check --capture-client-stacktrace and only collect artifacts through CH.prepare_logs().
Because SQL_STACKTRACES_LOG / C_STACKTRACES_LOG are just relative filenames, those jobs keep only the new 100-line stdout preview; the full sql_stacktraces.log / c_stacktraces.log never reaches the report there. In functional_tests.py they do not even cd into ci/tmp, so the files are written wherever the job cwd happens to be.
Please either thread an explicit stacktrace-output directory through clickhouse-test and teach the shared log collector to upload these files, or update every clickhouse-test caller before trimming the common timeout diagnostics globally.
…ives to the hung check The first run (https://github.com/ClickHouse/ClickHouse/actions/runs/29824157352) showed the detached SELECT was aborted by the server before the end-of-run hung check could see it: with the fast-test profile default max_execution_time=600, the speed estimator killed it with "Code: 160 ... Estimated query execution time (99683 s) is too long. Maximum: 600" at 13:10:33, ~90s before the hung check ran at 13:12:00. So system.processes was empty, the hung check reported "No queries hung", and no sql_stacktraces.log / c_stacktraces.log were written or attached. Add max_execution_time = 0 and max_estimated_execution_time = 0 so the query never ends and is guaranteed to still be running when the hung check fires. Related: ClickHouse#107173 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Verified the reporting fix end-to-end with a throwaway testing PR (#111213) that adds an artificial test leaving a query hung until the end-of-run hung check. What it shows:
Caveat: this run is the Linux |
Algunenano
left a comment
There was a problem hiding this comment.
LGTM with some minor comments:
- Please update the PR description. It has some outdated sentences.
- Let's add the dump paths for all stateless tests, not just fasttest.
This would be really useful to me to investigate the hungs in #111579. I managed to reproduce and fix the crashes, but not the hangs yet. Having traces would be of great help
| # clickhouse-test runs with cwd=temp_dir, so the full server stacktrace | ||
| # dumps it writes on a timeout / hung check land here. Attach them so | ||
| # the report links the full dumps (stdout keeps only a trimmed preview). | ||
| for stacktrace_log in ("sql_stacktraces.log", "c_stacktraces.log"): |
There was a problem hiding this comment.
Let's add these to stateless tests too please. Also, it'd be nice if these were global constants instead of hardcoded names. Maybe we can put them in a common place to share them with clickhouse-test (already has them as SQL_STACKTRACES_LOG / C_STACKTRACES_LOG) and functional_test
… log attachment Throwaway testing change (do NOT merge) on top of the brew-based lldb install fix (ClickHouse#112058). Adds a stateless test that never finishes: it detaches a long-running server-side query (with max_execution_time = 0 so the server does not self-kill it) into its own session via os.setsid, so it lingers in system.processes past the end of the run and the end-of-run hung check dumps and attaches the full server stacktraces (sql_stacktraces.log / c_stacktraces.log). Its foreground also hangs past --timeout so it is reported as a timeout. Related: ClickHouse#107173 Related: ClickHouse#112058 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When a
clickhouse-testtest times out — or the end-of-run hung check fires — the runner dumps server stacktraces. On the macOSFast test (arm_darwin)run this surfaced two reporting problems:system.stack_tracedump (over a thousand threads) and the lldb backtraces were inlined into the test description, floodingjob.log(~31k lines for a single timeout) and the per-test reportinfo(capped at 16384 bytes, so it was also truncated there).lldb --batch -p <pid>could not attach on the macOS runner and exited 1, andshell_get_outputdiscarded the command output, so the log kept onlyreturned non-zero exit status 1without the reason.This PR:
sql_stacktraces.log,c_stacktraces.log) and attaches them to the report fromfast_test.py; stdout keeps only atrim_for_logpreview. The files are per collector, not per test, because the hung check has no single owning test.task_for_pidrights);shutil.whichresolves the path because sudo resetsPATH. Linux is unchanged.shell_get_outputso the real failure reason is logged, bounded withtrim_for_logso a command that prints many lines and only then exits non-zero (e.g. lldb dumping backtraces) cannot floodjob.log.system.stack_tracedumpquery_id <> '' DESC, thread_id DESCso the wedged query's threads (and newest threads) come first.trim_for_log.The Darwin skip-list changes and the macOS no-JIT override are split out into separate pull requests.
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.8.1.199(included in26.8and later)