Skip to content

Return a reference from MergeTreeReaderWide::getOrAddStream - #123810

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:mergetree-reader-wide-stream-reference
Oct 5, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:mergetree-reader-wide-stream-reference

Conversation

@groeneai

@groeneai groeneai commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123160

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):

Description

Follow-up to #123160, as requested in #123160 (comment): a pointer that cannot be null should be a reference.

FileStreams::getOrCreate returns either the existing map entry or the one it has just inserted, and the only factory (the lambda in getOrAddStream) returns std::make_unique, so neither function can return null. Both now return MergeTreeReaderStream &, and the three callers that use the result take auto &. FileStreams::find stays a pointer, because it returns null for a missing stream.

No behaviour change. Checked with a debug build and 672 bucket|dynamic|subcolumn|low_cardinality stateless tests with randomized settings, run against binaries with and without the change: the results are identical.

🤖 Generated with Claude Code


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

Version info

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

`FileStreams::getOrCreate` returns either the existing map entry or the
one it just inserted, and the only factory (`getOrAddStream`'s lambda)
always returns `std::make_unique` (throws on failure, never null);
`release` moves the entry out and erases it under the same lock, so the
map never holds a null stream. Every caller either dereferenced the
pointer unchecked or discarded it, so return `MergeTreeReaderStream &`
from both functions instead.

`FileStreams::find` stays a pointer because it returns null for a
missing stream, and `getAll` stays a vector of pointers.

Follow-up to ClickHouse#123160, requested in
ClickHouse#123160 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-human PR origin: human review feedback on a groeneai PR labels Oct 4, 2026
@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand): 0 blockers, 0 majors, 1 nit
Finding Verdict
💡 The Related: link sat inside the template's HTML comment and did not render AGREE, moved to its own visible line

My own cold review of the diff and a second Gate B run on the corrected description: no findings.

@clickhouse-gh

clickhouse-gh Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7a6a16e]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, azure, sequential) ERROR IGNORED

AI Review

Summary

This PR tightens MergeTreeReaderWide's internal stream helpers from nullable pointers to non-null references. I reviewed the current diff, PR discussion, and the current MergeTreeReaderWide / MergeTreeReaderStream code paths around lazy stream creation, release, and reuse, and I did not find a correctness, lifetime, or concurrency regression relative to the existing ownership model.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 7a6a16e.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 92.10% 91.80% -0.30%
Branches 79.60% 79.60% +0.00%

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

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Oct 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7a6a16e28 with master 37a251ffa (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

8 translation units recompiled, 21 s compile time in total, 8 of them have a recent master baseline.

Job report

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 7a6a16e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_asan_ubsan, azure, sequential) not from this PR, which only turns a never-null stream pointer in MergeTreeReaderWide into a reference: the job hit its 9000 s timeout at test 1111 of 1116 with every test so far OK, so it uploaded no results. The same lane timed out on a master run and on another PR in the last 2 days a fix task is created (investigating at full effort, fixing-PR link to follow here)
PR rollup, red only because of the row above a fix task is created

All 149 check runs completed, Finish Workflow and Mergeable Check are green and CH Inc sync passed. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261004-090143

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Stateless tests (arm_asan_ubsan, azure, sequential) job timeout: #123849.

@PedroTadim
PedroTadim added this pull request to the merge queue Oct 5, 2026
Merged via the queue into ClickHouse:master with commit 915744a Oct 5, 2026
147 of 149 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 5, 2026
@clickhouse-gh clickhouse-gh Bot added comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... groeneai-origin-review-human PR origin: human review feedback on a groeneai 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants