Fix LOGICAL_ERROR "Table has no columns." on Merge over a dangling Alias#104919
Fix LOGICAL_ERROR "Table has no columns." on Merge over a dangling Alias#104919azat wants to merge 1 commit into
LOGICAL_ERROR "Table has no columns." on Merge over a dangling Alias#104919Conversation
…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
| { | ||
| return storage->getInMemoryMetadataPtr(context, false); | ||
| } | ||
| catch (...) |
There was a problem hiding this comment.
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?
LLVM Coverage Report
Changed lines: 72.50% (29/40) | lost baseline coverage: 2 line(s) · Uncovered code |
|
Not so easy, this breaks Replicated database - https://pastila.nl/?000a54ed/98f39c506155a9d6cf79db6c053c5ffc#m0agdNOIVWU14pvh/2YslQ==GCM |

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):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
LOGICAL_ERROR"Table has no columns." onMergeover a danglingAlias