Skip to content

Fix 00992_system_parts_race_condition_zookeeper_long: Fix NO_SUCH_COLUMN_IN_TABLE exception during merge after column drop - #96675

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-inject-required-columns-dropped-column
Feb 12, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-inject-required-columns-dropped-column

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 11, 2026 •

Copy link
Copy Markdown
Member

When injectRequiredColumns needs to inject a minimum-size physical column (because none of the requested columns are physical), it previously used the part's own columns. If a column was dropped from the table after the part was created, that dropped column could be selected as the minimum-size column, causing StorageSnapshot::getColumnsByNames to throw NO_SUCH_COLUMN_IN_TABLE. The merge task would then retry infinitely, causing the test to hang until timeout.

This was a regression from 6d0b4dc which changed from using metadata columns to part columns for finding the minimum-size column.

The fix filters part columns to only those also present in the current StorageSnapshot, ensuring the injected column is both physically readable from the part and resolvable by the metadata.

CI reports:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=aa46ae26c5f10dcfa86bad752fd565b4c38a8165&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20sequential%29 https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=79be3e6b519049d663b365863d6409ea4deea56e&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20sequential%29

Changelog category (leave one):

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

Version info

  • Merged into: 26.2.1.609

When `injectRequiredColumns` needs to inject a minimum-size physical column
(because none of the requested columns are physical), it previously used
the part's own columns. If a column was dropped from the table after the
part was created, that dropped column could be selected as the minimum-size
column, causing `StorageSnapshot::getColumnsByNames` to throw
`NO_SUCH_COLUMN_IN_TABLE`. The merge task would then retry infinitely,
causing the test to hang until timeout.

This was a regression from 6d0b4dc which changed from using metadata
columns to part columns for finding the minimum-size column.

The fix filters part columns to only those also present in the current
`StorageSnapshot`, ensuring the injected column is both physically readable
from the part and resolvable by the metadata.

CI reports:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=aa46ae26c5f10dcfa86bad752fd565b4c38a8165&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20sequential%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=79be3e6b519049d663b365863d6409ea4deea56e&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20sequential%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-milovidov alexey-milovidov changed the title Fix NO_SUCH_COLUMN_IN_TABLE exception during merge after column drop Fix 00992_system_parts_race_condition_zookeeper_long: Fix NO_SUCH_COLUMN_IN_TABLE exception during merge after column drop Feb 11, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-ci label Feb 11, 2026
…e after column drop

This test verifies that `injectRequiredColumns` does not pick a dropped
column (still physically present in parts) as the minimum-size column
to inject during vertical merge.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…r column drop

The previous test did not reliably trigger the bug because:
- With only 1-2 rows, compression overhead made all columns equal size,
  so `getColumnNameWithMinimumCompressedSize` didn't pick the dropped column.
- Using `mutations_sync = 2` waited for the DROP mutation to complete,
  so parts no longer had the dropped column physically.

The improved test uses:
- 10000 rows per part so `h` (UInt8) is clearly the smallest column.
- Failpoint `mt_select_parts_to_mutate_no_free_threads` to prevent
  background mutation application while allowing `OPTIMIZE TABLE FINAL`.
- `alter_sync = 0` so `ALTER DROP COLUMN` returns immediately.
- Column `value` added after insertion with constant DEFAULT so it has
  no physical file, making `have_at_least_one_physical_column` false.

Verified: fails with `NO_SUCH_COLUMN_IN_TABLE` on unfixed server,
passes on the fixed one.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e6a25f9]

Summary: ❌

job_name test_name status info comment
Performance Comparison (amd_release, master_head, 2/6) failure
Select historical data failure
Performance Comparison (amd_release, master_head, 6/6) failure
Select historical data failure

@alexey-milovidov alexey-milovidov self-assigned this Feb 12, 2026
@alexey-milovidov
alexey-milovidov merged commit 33dd760 into master Feb 12, 2026
128 of 130 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-inject-required-columns-dropped-column branch February 12, 2026 02:57
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 12, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @alexey-milovidov — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

tiandiwonder added a commit that referenced this pull request Aug 13, 2026
…solvable

Supersedes the rename mapping added by the previous commit on this branch. That
patch fixed the reported symptom of #103654; this one removes the defect the whole
family of failures in this block comes from, and so also closes #103116.

`injectRequiredColumns` injects the smallest physical column of a part when none of
the requested columns is physically present, only to learn the number of rows. That
column has to be both readable from the part and resolvable by the caller, which
looks names up in the metadata. The candidate set kept being taken from one side or
the other, which guarantees only one of the two properties, and each fix patched the
other side: `5c1db5fc661` used metadata columns and could find none with files in the
part (`LOGICAL_ERROR`), `6d0b4dc9885` switched to part columns which may be absent
from the metadata (`NO_SUCH_COLUMN_IN_TABLE`, #96675), and `1d2e2d1c6b2` intersected
the two but compared part names against metadata names, so renamed columns dropped
out (#103654), and reverted to part-only names when the intersection came out empty
(#103116).

Build the candidate set as the pairing instead: walk the metadata columns, map each
to its name in the part through `AlterConversions` exactly as
`injectRequiredColumnsRecursively` in the same file already does, skip the ones a
pending mutation drops because their data is stale, and keep those the part has files
for. Both properties then hold by construction. Sizes are looked up under the part's
name and the metadata name is what gets injected.

When that pairing is empty the two ways of getting there need different answers. If
the structure and the pending mutations account for every column the part holds, then
each requested column is legitimately absent and the part is read as rows of
defaults; no column has to be injected at all, because with adaptive granularity the
number of rows comes from the marks, and `getReadTaskColumns` already requires one
only when the granularity is not adaptive. If instead the part holds a column that is
neither in the structure nor being dropped, that is unexplained data — a part attached
after the schema moved on — and reporting defaults for it would hide rows that exist
on disk, so the read has to fail. `04011_detach_rename_attach_column` requires exactly
that for the renamed variant of it (#79110).

Closes: #103654
Closes: #103116

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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