Skip to content

Don't crash the hung check on non-UTF-8 bytes in the processlist - #113370

Merged
alexey-milovidov merged 4 commits into
masterfrom
fix-hung-check-processlist-decode
Aug 8, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
fix-hung-check-processlist-decode

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

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

The stateless-test hung check no longer crashes with UnicodeDecodeError when the processlist contains non-UTF-8 bytes; it reports the hung queries instead.

Under the AST fuzzer, query texts in system.processes can contain invalid UTF-8 sequences (for example fuzzed KILL QUERY WHERE query_id = ... texts). When the hung check found hung queries, print(processlist.decode()) in tests/clickhouse-test raised UnicodeDecodeError and the report showed a Python traceback instead of the processlist with stack traces, hiding the actual diagnostics. Decode with errors="replace" so the report always comes through.

Seen in a Stress test (amd_tsan) run: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106231&sha=e3b33b9fc008f1106279548b4d593e74c237f5c0&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 (the underlying hang there is unrelated — a DatabaseFilesystem mutex convoy, fix open as #112495).

Version info

  • Merged into: 26.8.1.1008 (included in 26.8 and later)

Under the AST fuzzer, query texts in `system.processes` can contain
invalid UTF-8 sequences (e.g. fuzzed `KILL QUERY WHERE query_id = ...`
texts). The hung check then died with `UnicodeDecodeError` in
`print(processlist.decode())` instead of reporting the hung queries.
Decode with `errors="replace"`.

Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106231&sha=e3b33b9fc008f1106279548b4d593e74c237f5c0&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
@clickhouse-gh

clickhouse-gh Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [88c005f]

Summary: ✅


AI Review

Summary

This PR makes the hung-query diagnostics in tests/clickhouse-test tolerant of non-UTF-8 bytes in system.processes output by decoding with errors="replace" before printing. I did not find correctness, safety, or PR-metadata issues in the current head; the change is narrowly scoped to the previously unhandled UnicodeDecodeError path, and the current PR CI is green.

Final Verdict

✅ No blocking or major issues found.

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice QOL improvement

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (04927315422). All four reds on c63680ee are unrelated to this Python-only change, and three of them already have their fix on master, which this merge pulls in:

Job Failure Status
Stateless tests (amd_asan_ubsan, distributed plan, parallel) Server died + Logical error: 'Bad cast from type DB::ColumnNullable to DB::ColumnString' in MergeTreeDataPartWriterOnDisk::initColumnsSubstreamsIfNeeded via MutateAllPartColumnsTask, from 03522_alter_modify_column_and_materialize_projection Fixed by #112501, merged into master on 2026-08-05 12:27 — after the base of the tested commit (2026-08-04 17:04). Closes #112459.
Stress test (amd_tsan) Logical error: 'Next task callback is not set for query ...' from Context::getClusterFunctionReadTaskCallback via StorageObjectStorageSource::createFileIterator, on a fuzzed SELECT count() FROM remoteSecure(..., 'test_view') over the SQL SECURITY DEFINER + s3Cluster view of 03667_view_with_s3_cluster_and_sql_security_definer Fixed by #113371 (81f1a793e40, "Propagate the cluster-function read-task callback into SQL SECURITY views"), also merged after the tested base.
Stress test (arm_debug) Logical error: 'ColumnBLOB should be converted to a regular column before usage' #113165, fixed by #111997.
Stress test (amd_msan) Hung check failed, possible deadlock found Two independent server-side hangs, both with fixes open: a cancelled SELECT ... FROM merge(REGEXP('.+'), 't.*') wedged in ReadFromMerge::createChildrenPlans → #113415, and UNDROP TABLE busy-waiting in DatabaseCatalog::undropTable (with a DROP DATABASE ... SYNC queued behind it) → #113263.

Note that the amd_msan hung_check.log of that very run is the positive check for this PR: the processlist of the hung queries is printed in full, with the invalid UTF-8 from the fuzzed query texts rendered as <?> replacement characters, and no UnicodeDecodeError traceback in place of the diagnostics.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master again (700410682b4). The only red on 04927315422 — Stress test (arm_debug) hung check — is unrelated to this Python-only change: all 74 hung queries in hung_check.log are wedged in DatabaseFilesystem::getTableImpl / getTablesIterator from 02722_database_filesystem.sh (e.g. a cancelled SELECT count() stuck for 2205 s). This is exactly the known DatabaseFilesystem deadlock this PR's description cites as its motivating example; the fix is still open as #112495. Fittingly, the hung check successfully printed the full processlist here thanks to this PR's own errors="replace" change.

@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 88c005f2f with master 31081d9f0 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 16bd8e494; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 690.17 MiB 687.14 MiB -3.03 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

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

Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +5.1 s (+8%) in total before that adjustment.

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Classic Python problem. Python is a bad programming language.

Merged via the queue into master with commit 438589f Aug 8, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-hung-check-processlist-decode branch August 8, 2026 22:46
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

3 participants