Repository navigation
Fix the race between KILL QUERY and the memory limit in 05315_freeform_structure_search_query_limits - #131525
Merged
Conversation
… memory limit The KILL case of `05315_freeform_structure_search_query_limits` lost a race against the query's own `max_memory_usage = 2000000000` on `Fast test (arm_darwin)` (PR ClickHouse#110102): no client could connect to the server for 8.4 s right after the poll saw the search under way, the search reached its limit and threw `MEMORY_LIMIT_EXCEEDED`, and the KILL then landed on the query while it was freeing its candidates. The KILL is now the poll itself and matches only while `peak_memory_usage` is between 10 MB and 1 GB, so a sent KILL is always seen by the search, and a late one matches nothing instead of racing the limit. The peak, not `memory_usage`: the current usage of a query that failed on its limit falls back through the window while it frees its candidates. An attempt in which the query ended before any KILL could be sent says nothing about KILL and is repeated, at most 3 times. `kill_throw_if_noop = 0` keeps the empty matches off stderr. The client output goes to a file and the client is bounded by `timeout 60`, as in the review change `ba2c2d703b40` of ClickHouse#123238, which never reached master. Related: ClickHouse#110102 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`yes | head` prints `yes: standard output: Broken pipe` to stderr where SIGPIPE is ignored, which fails a `.sh` test. The rows are byte-identical. This is part of the review change `ba2c2d703b40` by Alexey Milovidov on ClickHouse#123238, which never reached master. Co-Authored-By: Alexey Milovidov <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
`KILL QUERY ... ASYNC` also returns a row with `kill_status = finished` when the query left `system.processes` between the KILL's snapshot and the cancel. Such an attempt says nothing about KILL, so only `waiting` ends the attempts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
Internal second-model review (click to expand)
|
Collaborator
Author
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261114-024300 |
1 task done
Contributor
|
Workflow [PR], commit [e8bf361] Summary: ✅ AI ReviewSummaryThis test-only change combines polling with Final Verdict✅ Approve. |
Merged
via the queue into
ClickHouse:master
with commit Nov 19, 2026
b737158
606 of 608 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #110102
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fast test (arm_darwin)on #110102 failed the KILL case of this test withMEMORY_LIMIT_EXCEEDEDinstead ofQUERY_WAS_CANCELLED(report). It is not caused by #110102: 1 failure in about 170K runs since the test was added.The test polled
system.processesuntil the search reached 10 MB and only then started a client forKILL QUERY. On that runner no client of any test could connect to the server for 8.4 s right after the poll, so the search reached its ownmax_memory_usage = 2000000000and failed, and the KILL arrived while the query was freeing its candidates.Changes, test only:
peak_memory_usageis between 10 MB and 1 GB, so a sent KILL is always seen by the search and a late one matches nothing. The peak, becausememory_usagefalls back through that range while a failed query frees its memory.kill_statusother thanwaiting), the attempt is repeated, at most 3 times. A KILL that reaches the query ends the loop and its result is checked.kill_throw_if_noop = 0, the client output goes to a file undertimeout 60, and the rows are built withoutyes. The last two come from Alexey Milovidov's review commitba2c2d703b40on Stop theFreeformstructure search at the query's memory and time limits #123238, which never reached master.Validation on a debug build: delaying the KILL client by 8.45 s gives the CI result with the old test (stdout
MEMORY_LIMIT_EXCEEDED, empty stderr, 10 s), and the new test passes under the same delay. 100 randomized runs and 64 runs with 8 in parallel pass with no retry (p50 1.28 s). A local engine change that makes the search ignore the cancellation fails the new test 5/5.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131525]
Version info
26.11.1.2808-master(included in26.11and later)