Skip to content

remove readLockParts above loadStatistics - #124420

Merged
hanfei1991 merged 2 commits into
ClickHouse:masterfrom
hanfei1991:hanfei/remove-read-lock-parts
Oct 8, 2026
Merged

hanfei1991 merged 2 commits into
ClickHouse:masterfrom
hanfei1991:hanfei/remove-read-lock-parts

Conversation

@hanfei1991

@hanfei1991 hanfei1991 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

readLockParts above loadStatistics looks unnessesary

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

...


Workflow [PR]
Sync PR [sync-upstream/pr/124420]

Version info

  • Merged into: 26.10.1.1802-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0449b0f]

Summary: ✅


AI Review

Summary

This PR removes the extra readLockParts calls around part-statistics loading and updates the affected stateless tests to observe a new LoadedStatistics profile event instead of SharedPartsLocks. The lock removal itself looks fine, but the new counter is only wired into two MergeTreeData loops, so it does not yet consistently represent “parts whose statistics were loaded” across all supported statistics-planning paths.

Findings
  • ⚠️ Majors
    • [src/Common/ProfileEvents.cpp:1730] LoadedStatistics is exposed as a generic count of data parts whose statistics were loaded, but this PR increments it only in MergeTreeData::getConditionSelectivityEstimator and MergeTreeData::refreshStatistics. EXPLAIN WHATIF still loads stats through src/Storages/MergeTree/WhatIfStatisticalEstimator.cpp:42 without touching the counter, so ProfileEvents['LoadedStatistics'] becomes an unreliable oracle for planner statistics loads and the new tests only cover the current estimator path.
      Suggested fix: increment the counter in the common IMergeTreeDataPart::loadStatistics helpers, or at least cover the remaining planner path and rename/scope the event to what it actually measures.
Final Verdict
  • Status: ⚠️ Request changes
  • Keep the lock removal, but make LoadedStatistics consistent with every supported statistics-loading planner path, or narrow the metric name/description/tests to the exact scope you intend to count.

LLVM Coverage Report

Measured on commit 0449b0f.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.80% 79.80% +0.00%

Changed lines: Changed C/C++ lines covered: 19/19 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 7, 2026
@arsenmuk arsenmuk self-assigned this Oct 7, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Oct 7, 2026
M(SetsBuiltFromSubquery, "Number of `IN`/`JOIN` sets filled by running their subquery. A set taken from the prepared sets cache, or already built and reused, is not counted.", ValueType::Number) \
\
M(LoadedStatisticsMicroseconds, "Elapsed time of loading statistics from parts", ValueType::Microseconds) \
M(LoadedStatistics, "Number of data parts for which column statistics were loaded", ValueType::Number) \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoadedStatistics is now the test oracle for “how many part-statistics loads happened”, but this counter is only incremented in MergeTreeData::getConditionSelectivityEstimator and MergeTreeData::refreshStatistics. EXPLAIN WHATIF still loads per-part stats through src/Storages/MergeTree/WhatIfStatisticalEstimator.cpp:42 without touching the counter, so the new metric silently undercounts one supported statistics-planning path. Can we either move the increment into the common IMergeTreeDataPart::loadStatistics helpers, or at least narrow the event name/description to the exact path it measures?

@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 32 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 03dfbeb0-da42-4c49-9740-a8ae61a62176
  • MIRAI run: 52156e6e-84d6-453e-b386-32d64f74a3c3
  • PR check IDs:
    • clickbench_273808_1791420232
    • clickbench_274062_1791420357
    • clickbench_274158_1791420363
    • tpch_adapted_1_official_274265_1791420368
    • tpch_adapted_1_official_274363_1791420380
    • tpch_adapted_1_official_274460_1791420387

@hanfei1991
hanfei1991 added this pull request to the merge queue Oct 8, 2026
Merged via the queue into ClickHouse:master with commit 2336b9e Oct 8, 2026
152 checks passed
@hanfei1991
hanfei1991 deleted the hanfei/remove-read-lock-parts branch October 8, 2026 08:18
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 8, 2026
alexey-milovidov added a commit that referenced this pull request Oct 8, 2026
…r-part

Resolve conflicts in `MergeTreeData.cpp` with #124420: keep the per-part
`StatisticsCache` and the removal of `refreshStatistics`, take master's
removal of `readLockParts` around `loadStatistics` and the new
`LoadedStatistics` profile event. With the cache, `LoadedStatistics`
counts the parts whose statistics are collected for the estimator, from
the cache or from the part, so its description and the test comments are
updated accordingly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 11, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants