Skip to content

Fix LOGICAL_ERROR "Table has no columns." on Merge over a dangling Alias - #104919

Closed
azat wants to merge 1 commit into
ClickHouse:masterfrom
azat:alias-metadata-no-fallback
Closed

azat wants to merge 1 commit into
ClickHouse:masterfrom
azat:alias-metadata-no-fallback

Conversation

@azat

@azat azat commented May 14, 2026

Copy link
Copy Markdown
Member

Alias table returns empty metadata if the target does not exists, which will lead to LOGICAL_ERROR in the Merge

Simply returning empty metadata does not looks safe, looks like the only place where we need it is system tables.

So introduce separate method for them
(tryGetInMemoryMetadataPtrForSystemTable()) and remove this "return emtpy metadata fallback" in the Alias storage

Closes #104740
Alternative to #104790

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

Fix LOGICAL_ERROR "Table has no columns." on Merge over a dangling Alias

…g `Alias`

Alias table returns empty metadata if the target does not exists, which
will lead to LOGICAL_ERROR in the Merge

Simply returning empty metadata does not looks safe, looks like the only
place where we need it is system tables.

So introduce separate method for them
(tryGetInMemoryMetadataPtrForSystemTable()) and remove this "return
emtpy metadata fallback" in the Alias storage

Closes ClickHouse#104740
Alternative to ClickHouse#104790
@clickhouse-gh

clickhouse-gh Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [553faf1]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, db disk, old analyzer, 4/6) FAIL
test_replicated_database/test.py::test_alias_with_dropped_target FAIL cidb
Integration tests (arm_binary, distributed plan, 3/4) FAIL
test_replicated_database/test.py::test_alias_with_dropped_target FAIL cidb
Integration tests (amd_tsan, 4/6) FAIL
test_replicated_database/test.py::test_alias_with_dropped_target FAIL cidb
Integration tests (amd_msan, 4/6) FAIL
test_replicated_database/test.py::test_alias_with_dropped_target FAIL cidb
Integration tests (amd_llvm_coverage, 4/5) FAIL
test_replicated_database/test.py::test_alias_with_dropped_target FAIL cidb
BuzzHouse (amd_tsan) FAIL
Logical error: Distributed task iterator is not initialized (STID: 4662-3e65) FAIL cidb

AI Review

Summary

This PR removes StorageAlias metadata fallback to empty columns so Merge over a dangling Alias now raises UNKNOWN_TABLE instead of LOGICAL_ERROR, and it adds a regression test plus system.* call-site adjustments. The core fix direction is correct, but one new helper currently broadens behavior too much by suppressing unexpected exceptions.

Findings

⚠️ Majors

  • [src/Storages/System/tryGetInMemoryMetadataPtrForSystemTable.cpp:15] tryGetInMemoryMetadataPtrForSystemTable uses catch (...) and returns nullptr for all failures from getInMemoryMetadataPtr. This violates the intended contract (handle dangling Alias) by also hiding unrelated metadata failures from other storages, causing system.* tables to silently skip broken tables instead of surfacing the exception. Restrict handling to the expected case (for example Exception with ErrorCodes::UNKNOWN_TABLE, optionally gated to Alias) and rethrow other errors.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: narrow exception handling in tryGetInMemoryMetadataPtrForSystemTable to only the dangling-Alias/UNKNOWN_TABLE case and rethrow unexpected exceptions.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label May 14, 2026
{
return storage->getInMemoryMetadataPtr(context, false);
}
catch (...)

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.

catch (...) here suppresses metadata errors for every storage, not only dangling Alias with UNKNOWN_TABLE. As a result, system.* can silently skip tables on unrelated exceptions (for example metadata corruption or other logical exceptions), which hides real problems.

Can we narrow this to catch (const Exception & e) and return nullptr only for the expected dangling-alias case (e.code() == ErrorCodes::UNKNOWN_TABLE, optionally also storage->getName() == "Alias"), while rethrowing everything else?

@clickhouse-gh

clickhouse-gh Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 72.50% (29/40) | lost baseline coverage: 2 line(s) · Uncovered code

Full report · Diff report

@azat

azat commented May 14, 2026

Copy link
Copy Markdown
Member Author

@azat

azat commented May 18, 2026

Copy link
Copy Markdown
Member Author

This PR faced with reality, for now will get back to #104790

@azat azat closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logical error: 'Table has no columns.' (STID: 3593-5990)

1 participant