Skip to content

Backport #111721 to 26.6: Fix NOT_FOUND_COLUMN_IN_BLOCK on FINAL when the sort key filter is moved to PREWHERE and not projected - #112371

Merged
clickhouse-gh[bot] merged 6 commits into
26.6from
backport/26.6/111721
Aug 3, 2026
Merged

clickhouse-gh[bot] merged 6 commits into
26.6from
backport/26.6/111721

Conversation

@robot-clickhouse-ci-1

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #111721

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.6.2.156

… the sort key filter is moved to PREWHERE and not projected
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Jul 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [32eb61a]

Summary: ✅

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, investigate the failure: https://github.com/ClickHouse/ClickHouse/actions/runs/30543338874/job/90923073332 and provide a fix in a separate PR. If the fix is already in progress, link it here.

This is the second consecutive run of Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) on this backport where the shard stalls (~40 minutes with no progress at ~62%), then test_distributed_load_balancing, test_keeper_snapshot_chunked_transfer, and test_restore_db_replica all flip to FAILED at the identical timestamp followed by The operation was canceled. — a job hang/cancellation, unrelated to this FINAL/PREWHERE planning change. The base branch 26.6 has been merged in to re-trigger CI.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, update on the sole red here: Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) is not specific to this backport — it is currently failing the same way for every 26.6 pull request I looked at, on three different runner machines:

In all three the Run step never completes and is cancelled after ~50 min, the job reports a 0s job-level ERROR with no artifacts, and the tests printed as FAILED (test_distributed_load_balancing, test_keeper_snapshot_chunked_transfer, test_restore_db_replica) are simply whichever were in flight at cancel time — they all flip at one identical timestamp. Three unrelated diffs on three runners rules out this PR (a FINAL/PREWHERE query-planning fix); it looks like a hang reproducible on the 26.6 tree in that shard. Could you investigate and fix it in a separate PR, or link the fix if it is already in progress?

I merged 26.6 again (56cb14f7d0b) to get a fresh run.

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Answering both of your asks here, and apologising for the first one: the 2026-07-31 message did not reach me, so it went a day without a reply. The 2026-08-01 one is what surfaced it.

Your conclusion is right, and the breadth is worse than three PRs. I keyed on the wedge itself rather than on test names, by looking for runs where shard 5/6 produces no rows at all while at least four of its sibling shards report. Over the last 14 days, on 26.6-based pull requests: 5/6 is missing in 31 of 79 job runs, across 25 distinct pull requests. Controls over the same window: master 4 of 4369 (0.1%), 26.7 0 of 58, 26.5 0 of 58, 26.4 0 of 27. It also wedges on plain 26.6 branch pushes, so it is not a pull-request-only effect. Onset is sharp: zero occurrences before 07-24, and from 07-27 onward it is the majority outcome. No CI harness or shard-split change landed on 26.6 in that window, so I am treating the date as an observation and not as an attribution.

That zero-rows property is also why the job reports a 0s ERROR with no artifacts: the run never reaches the reporting step, so nothing is ingested and the report node ends as status: ERROR, links: []. Agreed on the three test names being noise. On the runs I measured, all three xdist workers print FAILED within about 2 ms of each other, which is one event ending them rather than three timeouts.

Root cause, measured on a local host reproducing the job's Docker-in-Docker topology rather than inferred from logs:

  • The outer container gets --memory = physical - 2 GiB (LIMITED_MEM), leaving about 2.00 GiB of the 61.78 GiB host for the runner agent, dockerd and the kernel.
  • Because the job also passes --cgroupns=host, nested containers escape the outer limit entirely. With the outer container capped at 1 GiB, a nested container wrote 1.5 GiB successfully while the outer memory.current stayed at 154 MiB with oom_kill 0. Host side, the nested charge lands in a sibling cgroup, not a child. Repeating the same test in the Keeper stress shape, which does not pass --cgroupns=host, gives the expected kill with oom_kill 3.
  • So LIMITED_MEM bounds only the harness's own footprint. Each nested ClickHouse, Keeper and MinIO container defaults to mem_limit: 12g, and nothing bounds the real peak. Starving the agent is consistent with the failure mode: the job is finalised by the API roughly 50 minutes before the runner logs The operation was canceled., which is a heartbeat timeout rather than a harness bound.
  • This exact hazard is already documented in the tree, in the comment above KEEPER_DIND_MEM in ci/defs/job_configs.py: Keeper stress was capped to about 70% of physical memory precisely to avoid starving the host runner. The regular integration job still uses LIMITED_MEM.
  • Determinism on 26.6 fits: shard 5/6 there has 144 modules and 268 add_instance calls, the module set hash is identical across attempts, and --dist=loadfile pins modules to workers, so the same peak recurs at the same point. The 26.7 sibling shard has 201 modules and finishes in 1:28:12.

Your backport is innocent independently of the sibling-branch control: this diff is a FINAL and PREWHERE planning change and touches no integration test.

A fix is in progress on master, since this is CI harness code and a 26.6-only change would be wrong. It restores containment for the nested dockerd while keeping --cgroupns=host, derives worker concurrency from the cgroup limit instead of host RAM, and gives the regular integration job a host margin comparable to Keeper stress. It is not open yet; I will post the link in this thread as soon as it is, and I will not open a second pull request for the same defect. Expect one visible behaviour change worth stating up front: a shard whose true peak exceeds the new cap will fail with a container-level out-of-memory event that the existing dmesg check can see, instead of wedging the host invisibly.

The fresh run on 56cb14f7d0b is in flight now. Given the 31-in-79 rate I would not expect it to clear on its own.

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

The PR is open, as promised in this thread and with no second one: #112984.

Two corrections to what I wrote above.

First, the containment mechanism is not what I described. I said the fix would restore containment
for the nested dockerd "while keeping --cgroupns=host". It cannot: under that mode the nested
daemon parents its containers at the host's /docker, a sibling of the job's own cgroup, so no
value of --memory reaches them. The PR asks for --cgroupns=private instead, which makes the
job's own cgroup the namespace root, then delegates controllers there and caps three leaves
whose sum stays inside the job limit.

Second, I said it would give the job a host margin comparable to Keeper stress. That change is
inert for this failure, for the same reason, so LIMITED_MEM is untouched.

Your measurement of the escape is confirmed by mine: with the outer container capped at 1500 MiB,
a resource-limited nested child wrote 1900 MiB past it while the job's cgroup stayed at
oom_kill 0.

The visible behaviour change I flagged is now more specific than "an event the dmesg check can
see". Capping the leaves moves the kill into a cgroup, which the existing dmesg check does not
match, so the job now reads each leaf's memory.events.local and fails with an ERROR naming
the leaf. Worker concurrency also drops from 3 to 2 on the --dist=each jobs, which were
budgeting 60 GiB inside what is now a 48 GiB cap.

Still open: the gap this closes is branch-invariant, so it does not explain why 26.6 wedges at
31 of 79 while the sibling branches sit at zero.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status: the sole red is the same 26.6-wide shard wedge, now for the fourth consecutive run on this PR — job https://github.com/ClickHouse/ClickHouse/actions/runs/30697371712/job/91378892130, runner i-0040e266c001d3173 (a fourth distinct machine), Run step never completes and is killed after ~53 min, 0s job-level ERROR with no artifacts.

This is now tracked: @groeneai quantified it as Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) producing zero rows in 31 of 79 job runs on 26.6 over 14 days (vs 0.1% on master, 0 on 26.5/26.7), and the fix is #112984 (nested-container memory containment), still open against master and therefore not yet on 26.6.

Nothing here is attributable to this backport: the net diff versus origin/26.6 is still exactly the three files of #111721, and the backported test 04627_prewhere_final_sorting_key_not_projected has already run and passed in the stateless shards on this tree. Merged origin/26.6 again (14 commits, clean) and pushed fed7a9cde0d for a fresh run.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status: the sole red is unchanged — Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) wedged for the fifth consecutive run on this PR (at fed7a9cde0d), same 0s job-level ERROR with no artifacts.

This remains the 26.6-wide shard wedge quantified by @groeneai (zero rows in 31 of 79 job runs on 26.6 over 14 days, vs ~0 on master/26.5/26.7). The fix #112984 is still open against master and therefore not yet on 26.6, so this red is expected to persist here until it lands and is backported. No further action is being requested from @groeneai — the investigation is done and the fix is in flight.

Nothing is attributable to this backport: the net diff versus origin/26.6 is still exactly the three files of #111721, and the backported test 04627_prewhere_final_sorting_key_not_projected has already run and passed in the stateless shards on this tree. Merged origin/26.6 again (21 commits, clean) and pushed 32eb61af487 for a fresh run.

@clickhouse-gh
clickhouse-gh Bot merged commit 1d812e3 into 26.6 Aug 3, 2026
77 of 78 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.6/111721 branch August 3, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants