Skip to content

Antalya 25.8 Backport of #85535 - Optimize selection of part list during query planning - #2640

Merged
zvonand merged 2 commits into
antalya-25.8from
backports/antalya-25.8/85535
Oct 25, 2026
Merged

zvonand merged 2 commits into
antalya-25.8from
backports/antalya-25.8/85535

Conversation

@zvonand

@zvonand zvonand commented Oct 22, 2026

Copy link
Copy Markdown
Member

Backport of ClickHouse#85535

Changelog category (leave one):

  • Performance Improvement

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

Up to 8x faster SELECT queries with heavy partition pruning on tables with 10K+ parts (ClickHouse#85535 by @jawm)

Optimize selection of part list during query planning
@zvonand zvonand added the backport Backport label Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [fee7859]

…an, GrypeScanServer / Grype Scan, GrypeScanKeeper / Grype Scan, Fast test)

Marked the unused `lock` parameter of the new `removePartsFromWorkingSetImmediatelyAndSetTemporaryState(remove, DataPartsLock &)` overload as unnamed, which fixes the unused-parameter build error.
@zvonand

zvonand commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

@blau-ai

@blau-ai

blau-ai commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

CI triage for #2640 (head fee7859)

Verdict: nothing here is caused by the backport's code. 4 red checks: 1 is a commit-metadata issue (DCO), the other 3 are an async-export flake, a fault-injection swarm flake, and an infra timeout — all in code paths this PR does not touch. The build matrix is fully green (asan/tsan/msan/ubsan/binary, unit tests, ~8000 stateless tests, all integration suites, stress, AST fuzzer, BuzzHouse), which is the strong signal that the lock/query-planning backport itself is sound.

This PR only changes MergeTree part-locking (exclusive std::mutex → SharedMutex read/write locks), the ReadFromMergeTree part-list passing, and adds new PartsLocks / SharedPartsLock* profile events. None of the failing tests exercise those paths.


1. DCO — ❌ fail → PR-related (metadata only), author action needed

The non-merge commit fee7859 "Fix CI failures (FinishCIReport, Grype…)" has no Signed-off-by: trailer, so cncf/dco2 rejects it.
Fix: sign off and update the branch, e.g.

git commit --amend --no-edit -s          # on fee7859
git push --force-with-lease origin HEAD:backports/antalya-25.8/85535

(I can't do this myself — it requires a force-push, which is outside my permissions.)

2. Stateless tests (amd_debug, parallel) — ❌ fail → flaky, not PR-related

Single failing test: 03608_export_merge_tree_part_filename_pattern. The first sub-test's rows came back empty:

 ---- Test: Default pattern {part_name}_{checksum}
-1	2020
-2	2020
-3	2020

But the very next check, SELECT count() FROM s3('…/2020_1_1_0_*.1.parquet'), returned 1 — the exported file exists — and sub-test 3 re-exports the same part 2020_1_1_0 and reads back all 3 rows fine. So ALTER TABLE … EXPORT PART (async) + sleep 3 raced the read of the hive-partitioned S3 destination: the SELECT * FROM dest1 ran before the object was listable, while the later count()/sub-test-3 reads had more time. Classic async-export/S3-listing flake. This test touches EXPORT PART + S3 hive output, none of which is in the PR diff.
Next step: safe to re-run. (If the test keeps flaking, it'd be worth replacing sleep 3 with a poll loop, but that's a test-infra issue independent of this PR.)

3. Regression aarch64 swarms — ❌ fail → flaky fault-injection, not PR-related

1 scenario failed out of 1535: /swarms/feature/feature/object storage cluster profile events with overloaded node. It overloads a node and then asserts work gets rerouted:

assert int(sent_to_non_matched_replica) > 0   # got 0
# sent_to_non_matched_replica = ProfileEvents['ObjectStorageClusterSentToNonMatchedReplica']

The injected overload didn't make the node slow enough within the window to trigger rerouting, so the counter stayed 0. This is swarm/object-storage-cluster replica routing — a timing-sensitive chaos test, and a known-troubled area on this branch (cf. #1873). The PR doesn't touch ObjectStorageClusterSentToNonMatchedReplica or swarm routing at all.
Next step: safe to re-run.

4. RegressionTestsAarch64 / Common (lightweight_delete) — ❌ fail → infra timeout, not a test failure

Conclusion is cancelled: "The job has exceeded the maximum execution time of 3h30m0s." No assertion failed and no report was uploaded (the job was killed mid-run). lightweight_delete is one of the heaviest regression modules and brushed the ceiling on a shared aarch64 runner.
I considered whether the std::mutex→SharedMutex parts-lock change could deadlock/slow deletes, but the evidence argues against it: all four stress runs (which hammer concurrent DDL/merges/mutations), every integration suite, and the mutation/delete stateless tests all passed — a parts-lock deadlock would have surfaced there, not only in one aarch64 module.
Next step: re-run; it should clear. If it times out again at exactly 3h30m, flag it for a perf look, but current evidence points to runner slowness, not a regression.


Bottom line: merge-wise, add the DCO sign-off (force-push) and re-run checks 2–4; none of the three test/infra reds indicate a problem in the backport.

🤖 Generated with Claude Code

@zvonand
zvonand merged commit 96a49f7 into antalya-25.8 Oct 25, 2026
523 of 529 checks passed
@zvonand zvonand added verified Approved for release antalya-25.8 labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants