Repository navigation
Do not report a server that rejects every query as a possible deadlock - #117995
Conversation
`Stress test (arm_release)` on master 7524705 failed with the single row `Hung check failed, possible deadlock found`, and nothing was hung. The server was alive and answering: the global memory tracker sat at `164.75 GiB` while `current RSS` was `7.16 GiB` and the limit `47.64 GiB`, so every allocation failed, down to the zero-byte check `CurrentMemoryTracker::check` does at the start of a connection. `clickhouse-test` retried the connection 180 times, all rejected with `MEMORY_LIMIT_EXCEEDED`, dumped an `lldb` backtrace of a perfectly healthy server and aborted with `Server is not responding`. The same signature - the tracked amount far above real usage, often above the memory of the machine - accounts for 10 of the 21 hung-check failures with a memory-limit message in the last 30 days of `default.checks`. All of them were filed as deadlocks, so the investigation starts by looking for a hang that is not there, and the recurrence of the memory-tracker fault is invisible in the CI database because it has no name of its own. `clickhouse-test` now keeps the last error the server itself answered with and says so instead of "not responding": a server that rejects a query received it. The stress job names the failing row after what the hung-check log shows - the processlist was reached and did hold hung queries, or the server was refusing everything - so the memory-tracker case is reported as itself. The row still fails; only its name changes. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=75247055068ba70941661c930840ee625a991adc&name_0=MasterCI&name_1=Stress%20test%20%28arm_release%29 Related: #117681 Related: #113060 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [a519342] Summary: ✅ AI ReviewSummaryPR #117995 distinguishes terminal HTTP query rejections from possible deadlocks in stress-test reports and preserves the server's symbolic error name. Reviewed both changed files at Final VerdictStatus: ✅ Approve |
|
Why wasn't memory freed, and are there any settings to prevent that? |
Two findings from the review of the previous commit. `check_server_started.last_server_error` was sticky: a retry that got an `HTTPError` left the message standing even when a later retry failed to reach the server at all, so `ConnectionError` after `MEMORY_LIMIT_EXCEEDED` was reported as a server that rejects queries. It is now set on every retry -- to the response when the retry got one, to the empty string when it did not -- and cleared on the two paths that leave the loop without retrying, so it always holds the outcome of the last attempt. `hung_check_failure_name` classified on any `(total) memory limit exceeded` line anywhere in the log, which misfiled a run whose early retries hit the memory tracker but which ended on a refused connection, and left every other rejection (`CANNOT_SCHEDULE_TASK`, for one) on the deadlock row. It now reads the single terminal line `clickhouse-test` prints -- `Server rejects queries. Cannot query the server version: ...` -- and names the row after the error the server answered with, so the rejections do not share one name.
|
🕵 The memory was freed. What was not released is the counter. I pulled the artifacts of the run in the description ( The bytes were never there
So this is drift in the global Why it never comes backThe global tracker is a plain counter; nothing re-synchronises it with reality. The if (first_run || total_memory_tracker.get() < 0) [[unlikely]]
MemoryTracker::updateAllocated(resident, /*log_change=*/true);
else if (correct_tracker)
MemoryTracker::updateAllocated(resident, /*log_change=*/false);
The setting
With it, every tick overwrites the tracker with the measured value and the difference is Nothing else prevents it. I have not opened a PR for the default, because switching it changes what One thing this run also showsThe hung check deliberately passes What I could not answerWhere the phantom bytes come from. It arrives suddenly, in one or two very large steps, |
…limit-not-deadlock
`hung_check_failure_name` read only the marker the startup probe prints, so a hung check that got through startup and was then rejected on the processlist query itself -- `MEMORY_LIMIT_EXCEEDED` out of `get_processlist_size`, the same memory tracker drift, only reached one step later -- had neither marker in its log and went back on the deadlock row. `clickhouse-test` now prints the same `Server rejects queries.` marker on that path, and only for an `HTTPError`: an HTTP response is an answer from the server, so it rejected the query rather than being unreachable, while a transport failure there is exactly the case that may be a hang and must keep the deadlock name. `hung_check_failure_name` keys off the shared prefix. The error name is now taken from the last upper-case token of the line instead of the end of it, because a server exception carries a trailing `(version 26.9.1.1)` that the anchored match could not see past, which would have collapsed every rejection into one unnamed row. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…limit-not-deadlock
`hung_check_failure_name` returned `Server rejects all queries, ...` for both places that print the `Server rejects queries.` marker, but the processlist marker is only reachable after `check_server_started` has already succeeded, so on that path the version query and the preparation queries went through and "all queries" overstated the failure. The row name is now derived from the rest of the marker: a rejected startup probe (`Cannot query the server version`) still says `Server rejects all queries`, a rejected hung-check query (`Cannot get the processlist size`) says `Server rejects the processlist query`, and the error name is appended as before. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…obal memory tracker A server whose global MemoryTracker::amount has drifted far above its real memory usage refuses every allocation, down to the zero-byte CurrentMemoryTracker::check() at connection start, while using a fraction of its limit. In CI this lands as "Hung check failed, possible deadlock found", so a real deadlock in the same run is invisible. ClickHouse#118094 and ClickHouse#117738 correct the counter and ClickHouse#117995 stops the harness calling it a deadlock, but as ClickHouse#118094 says itself, where the phantom bytes come from is still unknown. Nothing records the add, for two structural reasons rather than bad luck. The blocked-Global branch of allocImpl does amount.fetch_add, rss.fetch_add, updatePeak and CurrentMetrics::add, then returns without ever reaching commitAllocation, so it emits no hard-limit check, no trace, no ProfileEvent. Everything that does reach commitAllocation is reported by incrementAllocationWithoutCheck, whose payload lands in system.trace_log, the sink the wedge itself breaks: in the measured run, 109 failed trace_log flushes, 112 metric_log, 109 query_log, and not one memory trace of 1 GiB or more in the whole run. The one channel that survives is the log file, which carried all 31,310 refusal messages through the full 14-minute wedge. So detect a single allocation at or above the new server setting min_allocation_size_to_log_stack_trace on the two places where the global amount grows and is not reverted, report it through TraceSender as a new TraceType::MemoryLargeAllocation, and let TraceCollector symbolize it and mirror one LOG_ERROR before the trace_log insert, so the stack survives when the insert does not. This follows the pattern azat established in e7a58e7, which added MemoryAllocatedWithoutCheck to trace_log and deliberately removed direct logging from MemoryTracker because it can deadlock: the send site captures an unsymbolized stack, since StackTrace::toString takes the symbolizer cache mutex and allocates. The wire format is deliberately untouched. The record is already 510 of the 512 bytes that keep the pipe write atomic, so the tracker total is read by the collector at log time and labelled as such rather than carried in the record, and no field is repurposed. Traces are budgeted at 10 because symbolizing is expensive and the trigger repeats. The budget refills only when the setting transitions from 0 to a nonzero value: the config-reload callback calls the setter on every reload, so refilling per call would have left no bound at all on a server that reloads periodically. The setter refuses a nonzero threshold when no trace collector is running and warns once, because the collector only exists when trace_log is configured and clickhouse-local never creates one; without it the setting could only capture a stack and discard it. It is registered in collectChangeableServerSettings through its getter so system.server_settings reports the effective value after such a refusal. Only the global tracker is instrumented. Process, User and Thread trackers die with their query and their drift is already visible in query_log.memory_usage, so instrumenting them would fire once per large query. adjustOnBackgroundTaskEnd and updateAllocated are left alone because measurement excludes them: both write amount and never rss, so neither can produce the inflated rss reading these reports carry. Default 0 keeps the diagnostic off; 8Gi under tests/config so CI gets it. This does not fix the drift. It makes the next occurrence carry the stack, which is the input issue ClickHouse#117681 is missing. Related: ClickHouse#117681 Co-Authored-By: Claude Opus 5 <[email protected]>
…limit-not-deadlock
…host rejections The server body of an `HTTPError` can span several lines, with the error name (e.g. `MEMORY_LIMIT_EXCEEDED`) on a later line than the `Server rejects queries.` marker, so `hung_check_failure_name` in `stress.py` did not see it. Fold the error into one line in both places that print the marker. The cloud sticky-host probe now also reports a host that answers every retry with an error as rejecting queries instead of not responding. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…limit-not-deadlock
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117995&sha=218af5742f9d933c6d221497b7b51456426a5fc8&name_0=PR&name_1=Stress%20test%20%28arm_msan%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. This is a real hung query, unrelated to this PR (which only changes how the row is named): a cancelled |
|
The fix is already in progress: #108357. I checked the
Only a review is missing on #108357. At head |
|
🕵 Thanks, @groeneai — confirmed. The |
…limit-not-deadlock Conflict in `tests/clickhouse-test`: master replaced the HTTP sticky-host probe with `check_native_sni_override_started` (native client with `--tls-sni-override`). Took master's version; the PR's sticky-host rejection message relied on `check_server_started.last_server_error`, which the new native probe does not produce, so it is dropped.
|
🕵 The |
…ected during the hung check An `HTTPError` from a setup query such as `collect_build_flags` escaped `main` without any marker, so the stress test still reported a possible deadlock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`create_common_database` wraps the `HTTPError` into `RuntimeError`, and the database setup then wraps that into `StopTesting`, so the outer `except HTTPError` never saw a rejected `CREATE DATABASE` during the hung check, and the stress test still named the row `Hung check failed, possible deadlock found`. Look for the `HTTPError` through `__cause__` / `__context__` in both the `HTTPError` and `StopTesting` handlers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k is rejected When the hung check polling loop sees running queries, the stacktrace query fails, and the `get_processlist_size` recheck is answered with an `HTTPError` (e.g. `MEMORY_LIMIT_EXCEEDED`), the recheck's exception was swallowed and the stress job still named the row `Hung check failed, possible deadlock found`. Keep the recheck's exception and print the shared `Server rejects queries.` marker for it. A transport failure or a recheck that still sees running queries stays on the deadlock path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…check outcome A rejection of the polling query was printed as the `Server rejects queries.` marker right away. But it is not necessarily terminal: when earlier probes saw running queries, `hung_count` stays positive and the check goes on to collect stacktraces and to recheck the processlist. If that recheck still saw running queries, or failed with a transport error, nothing replaced the earlier marker, and the stress job named the row `Server rejects the processlist query` instead of a possible deadlock. Record the rejection of the polling query and print the marker once, after the outcome is known: the recheck supersedes it, and so do hung queries found in the processlist. Checked by running the hung-check block with stubbed queries and naming the output with `hung_check_failure_name`: - polling `HTTPError` on the first probe: rejection; - polling `1`, `HTTPError`, stacktrace timeout, recheck `1`: possible deadlock; - the same with the recheck raising `ConnectionError`: possible deadlock; - the same with the recheck raising `HTTPError`: rejection; - the same with the recheck returning `0`: rejection (the only failure); - polling `1`, `HTTPError`, stacktraces collected: possible deadlock. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 The only CI failure on 15a5ae2, |
Stress test (arm_release)on master75247055068ba70941661c930840ee625a991adcfailed with one row,
Hung check failed, possible deadlock found, and nothingwas hung. The server was alive and answering: the global memory tracker sat at
164.75 GiBwhilecurrent RSSwas7.16 GiBand the limit47.64 GiB, soevery allocation failed — including the zero-byte check
CurrentMemoryTracker::checkdoes at the start of a connection.
clickhouse-testretried the connection 180times, all rejected with
MEMORY_LIMIT_EXCEEDED, dumped anlldbbacktrace of ahealthy server and aborted with
Server is not responding.The same signature — the tracked amount far above real usage, and above the
memory of the machine — accounts for 10 of the 21 hung-check failures carrying a
memory-limit message in the last 30 days of
default.checks:All of them were filed as deadlocks, so an investigation starts by looking for a
hang that is not there, and the recurrence of the memory-tracker fault itself is
invisible in the CI database because it has no name of its own. (The other 11
rows are ordinary memory pressure — the tracker close to both RSS and the limit —
and keep the name they have.)
This does not fix the memory tracker. It stops the report from misnaming what
happened:
clickhouse-testkeeps the last error the server itself answered with and saysso instead of "not responding" — a server that rejects a query received it.
processlist was reached and did hold hung queries, or the server was refusing
everything. The row still fails, only its name changes.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=75247055068ba70941661c930840ee625a991adc&name_0=MasterCI&name_1=Stress%20test%20%28arm_release%29
Related: #117681
Related: #113060
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/117995]
Version info
26.12.1.208-master(included in26.12and later)