Skip to content

Re-add test 04756 for reading a Nested sibling beside a re-added subcolumn - #113777

Merged
PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/readd-04756-nested-sibling-test
Aug 7, 2026
Merged

PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/readd-04756-nested-sibling-test

Conversation

@groeneai

@groeneai groeneai commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #112997
Related: #113225
Related: #113461

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

Tests only. #113461 reverted #112997 together with its test; the shapes that test covers are fixed by #113225, so it is re-added on its own to pin that fix, as asked in #112997.

It is a live witness, not a control. Reverting #113225's getSubcolumnsOfNested and type-computation repairs makes three of the eleven assertions report mismatching rows where 0 is correct:

assertion correct with #113225 reverted
missing subcolumn first 199 0 0 199 100 100
many granules 199 0 199 100
wrapped element types 199 0 0 199 66 100

Deterministic, three rounds. The remaining eight assertions (part type, reader header, prefetch limit, the two sibling-ordering cases, prefetch off, and the Compact-part pair) hold on both arms and are kept as controls; none was weakened to make the test pass.

The no-random-merge-tree-settings tag the pre-revert file carried is dropped rather than restored. The test already pins index_granularity, min_bytes_for_wide_part and min_rows_for_wide_part in its CREATE TABLE ... SETTINGS clause, which takes precedence over runner injection, and share_nested_offsets is not randomized at all. Measured 250 randomized runs green without it (200 at --jobs 8, 50 at --jobs 1), plus 50 more with default_compression_codec forced to ZSTD, since that tag also pinned the codec to LZ4. Keeping randomization on is preferable to a blanket opt-out.

The test asserts content, not length, which the defect preserves, and asserts via EXPLAIN header = 1 that both columns reach the reader, since query_plan_remove_unused_columns would otherwise prune the subcolumn and the shapes would stop exercising the bug.

Version info

  • Merged into: 26.8.1.963 (included in 26.8 and later)

…olumn

PR ClickHouse#113461 reverted ClickHouse#112997 along with its test. The shapes that test covers
are fixed by ClickHouse#113225, so the test is re-added on its own to pin that fix, as
requested in ClickHouse#112997.

Three of its eleven assertions are live witnesses for ClickHouse#113225: reverting that
PR's `getSubcolumnsOfNested` and type-computation repairs makes `missing
subcolumn first`, `many granules` and `wrapped element types` report 100, 100
and 66 mismatching rows where 0 is correct. The other eight are controls
(part type, reader header, prefetch limit, sibling ordering, prefetch off and
the Compact-part pair) and are kept as such.

The `no-random-merge-tree-settings` tag the pre-revert file carried is
dropped. The test already pins `index_granularity`, `min_bytes_for_wide_part`
and `min_rows_for_wide_part` in its `CREATE TABLE ... SETTINGS` clause, which
takes precedence over runner injection, and `share_nested_offsets` is not
randomized at all. Measured 250 randomized runs green without the tag (200 at
--jobs 8, 50 at --jobs 1), plus 50 more with `default_compression_codec`
forced to ZSTD, since the tag also pinned that codec to LZ4. Keeping CI
randomization on is preferable to a blanket opt-out.
The test file was restored from the commit that ClickHouse#113461 reverted, so three of
its comments described ClickHouse#112997's implementation rather than the tree the test
now runs against.

Two of them named prefetch stream ownership: the invariant that a prefetch
positions a stream for the column that issued it, so a sibling sharing that
stream must still seek. ClickHouse#113461 reverted the mechanism that held it. On master
prefetched_streams is again a std::unordered_set<std::string> consulted by a
bare contains, with no owner, so a reader that finds a stream prefetched does
not seek regardless of which column prefetched it. Both comments now state what
the assertions below them actually pin: under share_nested_offsets a re-added
Nested member and its siblings share one offsets stream, so the member's group
and element types must be rebuilt from metadata or the siblings read wrong
values, and that resolution must hold for every mark rather than only the first.

The direction matters and is measured. Comparing the committed reference against
a build with ClickHouse#113225's repairs reverted, sum(length(nb)) over the re-added
member reads 199 on both arms in all three live assertions; every field that
moves is a countIf over a sibling. A comment claiming the re-added member reads
wrong would be refutable from the test's own reference file.

The third is the filesystem_prefetches_limit block, which ran to four lines.
The arithmetic it ended with is re-derivable from the queries below it and from
the assertion itself, which spells out the same bound, so that line is dropped
and the invariant a reader cannot re-derive is kept: read the effective value
rather than pinning it, so a restrictive limit fails this test instead of
silencing it.

Comment text only. No assertion, expected value, setting or table definition
changes, and the reference file is untouched.
The test pinned only local_filesystem_read_prefetch, but MergeTreeReaderWide
chooses which of the two flags to read by storage rather than by the flag the
query sets:

    bool do_prefetch = data_part_info_for_read->getDataPartStorage()->isStoredOnRemoteDisk()
        ? settings.read_settings.remote_fs_settings.prefetch
        : settings.read_settings.local_fs_settings.prefetch;

so on remote parts the pinned flag was not consulted at all. The s3 stateless
jobs put MergeTree parts on object storage and, unlike the azure job, do not
pass --no-random-settings, while the runner randomizes
remote_filesystem_read_prefetch over 0 and 1. A draw of 0 there removed the
prefetch path from the three assertions that are live without the fix this test
pins, so they would have passed on a binary lacking it; the same draw inverted
the "prefetch off" control, which pinned only the local flag and would then have
run with prefetching enabled.

Both sites now pin the remote flag alongside the local one, keeping their
existing meanings: 1 where the test wants prefetching and 0 in the control. On
a machine with no object storage the addition is inert, since the remote branch
is never taken, so this restores coverage on s3 runs rather than changing what
the test measures locally. No assertion, expected value or table definition
changes and the reference file is untouched.
@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Two review rounds over this branch, each with an independent cold reviewer plus a separate
adjudicating model reading only the resulting code. Round 1 found one substantive issue and two
wording issues; round 2 re-reviewed the fix and found nothing. Verdicts below.

❌ Blockers

None.

⚠️ Major (fixed)

Only the local prefetch flag was pinned, so the test went vacuous on s3 runs.
MergeTreeReaderWide::prefetchForAllColumns picks which of the two prefetch flags to read by
storage, not by the flag the query sets:

bool do_prefetch = data_part_info_for_read->getDataPartStorage()->isStoredOnRemoteDisk()
    ? settings.read_settings.remote_fs_settings.prefetch
    : settings.read_settings.local_fs_settings.prefetch;

The s3 stateless jobs put MergeTree parts on object storage (tests/config/install.sh sets
USE_S3_STORAGE_FOR_MERGE_TREE=1 for --s3-storage and links
s3_storage_policy_for_merge_tree_by_default.xml) and, unlike the azure job, do not pass
--no-random-settings, while tests/clickhouse-test randomizes
remote_filesystem_read_prefetch over 0 and 1. A draw of 0 removed the prefetch path from the
three assertions that are live without #113225, so they would have passed on a binary lacking it;
the same draw also inverted the prefetch off control, which pinned only the local flag. The
loss is real rather than theoretical: over the last 60 days the pre-revert version of this test
ran 4236 times on Stateless tests (amd_tsan, s3 storage, parallel, 1/3) alone, plus four
further s3 flavours.

Fixed by pinning the remote flag beside the local one at both sites, each keeping its existing
value: 1 where the test wants prefetching, 0 in the control. Two lines; no assertion,
expected value, table definition or reference line changed. On a machine with no object storage
the addition is inert, verified rather than assumed (system.disks has one Local disk with
object_storage_type = None, so the remote branch is never taken), which is why this restores
coverage on s3 runs instead of changing what the test measures. Precedent for the paired form:
04326_json_advanced_shared_data_file_open.sh.

Severity was major rather than blocker because every failure mode is a silently passing test, not
a wrong verdict about #113225 and not a red on a correct binary.

💡 Nits

  • Two wording items in the PR description and the validation table, fixed. The Related:
    link for Fix wrong results reading a Nested sibling beside a re-added subcolumn #112997 was inside the template's HTML comment and would not have rendered; three
    visible Related: lines are now published. One row of the validation table read as if the
    shipped file disabled settings randomization, when only the determinism measurement did; it now
    separates the two.
  • The prefetch off row is a control, not a dead assertion. It reads 199 0 with and
    without Fix wrong results reading a re-added Nested member subcolumn #113225, which is the point: it shows the defect is reachable only with prefetching
    enabled. Recorded so it is not mistaken for a row that stopped pinning anything. No change.

Verified and unchanged

The reference file is byte-identical to the pre-revert one, and the query file differs from it
only by the dropped no-random-merge-tree-settings tag line, the two prefetch settings lines and
three comment texts, with zero assertion, expected-value or table-definition edits. The three
corrected comments were necessary: they described the prefetch stream ownership that #113461
reverted, so on master (prefetched_streams is again a plain std::unordered_set<std::string>
consulted by a bare contains) the old text was false. All eleven labels pair with the eleven
reference lines in order, and the test's raw output is byte-identical to the reference with
nothing on stderr, run alone with randomization both on and off, 50 runs each.

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, in the form this PR needs: the test is a witness, so the deterministic measurement is that it FAILS on demand when #113225 is reverted. Three rounds, identical output each time; that determinism arm was measured with randomization disabled and one test, while the shipped test deliberately keeps CI randomization ON (see row g). On the current tree it passes with randomization on and off, and its raw statement output is byte-identical to the committed reference file, with no output on stderr.
b Root cause explained? The defect the test pins is #113225's, already merged and described there: getSubcolumnsOfNested skipped subcolumns instead of grouping by the column in storage, and fillMissingColumns computed the offsets-branch type from a possibly remapped pair, so a Nested member's subcolumn read beside its sibling produced a wrongly typed or wrongly parented column. This PR adds no fix; it restores the coverage that #113461 removed together with #112997.
c Fix matches root cause? Tests only, so no fix to match. The measured question instead is whether the restored test still pins anything now that its original PR is reverted, and it does: reverting #113225 makes three of its eleven assertions report mismatching rows.
d Test intent preserved / new tests added? Yes. The two files are restored from the revert's parent commit, byte-identical apart from removing the no-random-merge-tree-settings tag line and three comment-text corrections: two comments described the prefetch stream ownership that #113461 reverted, and a third ran to four lines. Comment text only, so the reference file is untouched. No expected value was edited to turn a red line green, and no assertion was weakened; the three live assertions and the eight controls are all kept as they were, and the per-assertion liveness split is reported in the PR body rather than used to prune rows.
e Both directions demonstrated? Yes. Passes on the current build; fails deterministically (3/3) on a mutant with #113225's getSubcolumnsOfNested and type-computation repairs reverted, which builds to a distinct Build ID (39b2ac52). Both arms had the server buildId asserted against readelf -n before any verdict, and the untagged final shape was re-checked on the mutant so the liveness claim describes the file that ships, not the tagged one it was first measured with.
f Fix is general across code paths? Tests only. The test itself covers Wide and Compact parts, prefetch on and off, three sibling orderings, a many-granule fixture and wrapped element types, so the eleven rows span the paths #113225 touched rather than a single shape.
g Fix generalizes across inputs (params/datatypes/wrappers)? The wrapped element types row exercises Array(Nullable(UInt64)), Array(LowCardinality(String)) and Array(Tuple(...)) element types and is one of the three live assertions. Map is not covered: a Nested member is an Array(Tuple(...)), so a Map column is not a sibling of the shape under test. Randomization is deliberately left ON: measured 250 runs green without the dropped tag (200 at --jobs 8, 50 at --jobs 1), plus 50 with default_compression_codec forced to ZSTD, since that tag also pinned the codec to LZ4. A positive control confirmed the codec override actually reached the server (a bogus codec value is rejected as itself).
h Backward compatible? (maintainer-approved exception only) Yes, trivially: two files under tests/queries/0_stateless/, no source change, no setting, no format. The diff touches 0 files under src/.
i Invariants and contracts preserved? No source contract is touched. Test-number freedom was re-checked on all three dimensions rather than inherited: absent from live origin/master by a git ls-tree -r --name-only origin/master tests/queries/0_stateless/ listing grepped for 04756, returning 0 (positive controls 00001_count_hits and 04770 both returning 2, since the contents API truncates); no open PR adds a 04756_* path, swept over every open PR by file list with the page-capped ones re-probed through paginated REST, 0 hits against a non-vacuous control; and the fleet-worktree matches are one stem whose .sql is md5-identical to the pre-revert file, i.e. stale checkouts rather than a collision. check_gaps_in_tests_numbers over the simulated merged CI file list returns [], with an injected 99999_probe.sql returning Gap (4811, 99999) > 100 as the positive control.

@PedroTadim PedroTadim self-assigned this Aug 7, 2026
@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b61f5ba]

Summary: ❌

job_name test_name status info comment
Stress test (arm_tsan) FAIL
Logical error: Unexpected return type from A. Expected B. Got C. Action: (STID: 1611-447a) FAIL cidb IGNORED

AI Review

Summary

This PR re-adds stateless test 04756 to cover the prefetch-on shared-offsets case for a re-added Nested member beside sibling columns after #113225 and #113461. I did not find a new correctness or flakiness issue in the current diff: the earlier remote-prefetch gap is fixed by pinning both local and remote prefetch flags, explicit table SETTINGS still win over runner-injected randomized MergeTree settings, and the remaining randomized read paths still exercise the same MergeTreeReaderWide prefetch/seek logic the test is meant to pin.

Final Verdict

✅ No new findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 7, 2026
@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

cc @rienath, could you review this? It re-adds a stateless test that #113461 removed along with #112997: it pins #113225's Nested-member subcolumn grouping and element-type computation, so three of its eleven assertions report mismatching sibling rows if that fix is reverted, and the other eight are controls.

@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b61f5ba8d with master e5c489c41 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 8bb9b45c8; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 690.17 MiB 687.14 MiB -3.03 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

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

Job report

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - b61f5ba

Every failure below has an owner: a fixing PR (ours 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
Stress test (arm_tsan) / Logical error: Unexpected return type from equals. Expected Nullable(UInt8). Got UInt8 (STID 1611-447a) trunk bug, not PR-caused. A set skip index evaluates a predicate whose granule is non-Nullable while the action expects Nullable(UInt8); the failing query is modulo(t, 19) = 16 shaped. Breadth over 30 days on the exact signature (test_name containing Unexpected return type from A. Expected B. Got C.): 46 rows / 40 distinct PRs / 3 master, most recent 2026-08-07 11:07:04. This PR only re-adds a stateless test file. #110338 (ours, open)
Sync - CH Inc sync (private, not actionable by me)

All 175 check-runs completed (58 success, 116 skipped, 1 failure); Config Workflow and
Finish Workflow both success. CIDB records 110,491 result rows across 61 checks on this commit,
of which exactly 1 is FAIL (the row above).

#110338 ("Fix LOGICAL_ERROR in set skip index when predicate is Nullable but granule is not") is
the open fix for this sub-signature and both directions were verified locally when it was written,
so it is linked here as the owner. It is not merged, so nothing needs picking up onto this branch.

Session id: cron:our-pr-ci-monitor:20260807-130000

@PedroTadim
PedroTadim added this pull request to the merge queue Aug 7, 2026
Merged via the queue into ClickHouse:master with commit 8a14c7c Aug 7, 2026
178 of 180 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 7, 2026
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 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 groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-ci 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