Repository navigation
Fix logical error when table is dropped before distributed plan task deserialization - #106944
Conversation
…deserialization A table can be dropped concurrently between the coordinator serializing a distributed query plan and a worker task deserializing it, so a failed catalog lookup in ReadFromMergeTree::deserialize is a reachable runtime condition, not an invariant violation. Throw UNKNOWN_TABLE (as the parallel replicas path does in the same scenario) instead of LOGICAL_ERROR, which aborts the server in debug and sanitizer builds. Also turn the unchecked MergeTreeData reference cast into a checked one: the same race can resolve the name to a non-MergeTree table recreated under the same name, which would crash with std::bad_cast. Fixes #106906 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [d260520] Summary: ✅
AI ReviewSummaryThis PR changes Findings
Tests
Final VerdictStatus: Minimum required action: preserve table identity across distributed-plan serialization/deserialization, and add regression coverage for the replacement-table race. |
| auto storage_ptr = DatabaseCatalog::instance().tryGetTable(table_id, ctx.context); | ||
| if (!storage_ptr) | ||
| throw Exception(ErrorCodes::LOGICAL_ERROR, "Table {}.{} not found in catalog", database_name, table_name); | ||
| auto storage_ptr = DatabaseCatalog::instance().getTable(table_id, ctx.context); |
There was a problem hiding this comment.
This still resolves the serialized ReadFromMergeTree by database.table only, so the same race can silently bind the task to a replacement table instead of failing. A concrete sequence is: the coordinator serializes db.t for a MergeTree with UUID U1; db.t is dropped and recreated as another MergeTree with the same schema and UUID U2; the worker deserializes StorageID(database_name, table_name) with no UUID, getTable returns U2, the dynamic_cast passes, and the header compatibility check also passes. The query can then read data from the new table. The part-name check is not enough for bucketed reads either, because part names such as all_1_1_0 can be reused by the replacement table.
Please serialize the original StorageID UUID when it is present and resolve/check by UUID during deserialization, failing with a normal UNKNOWN_TABLE/TABLE_UUID_MISMATCH style exception if the original table is gone or the name now belongs to a different table.
There was a problem hiding this comment.
@clickhouse-gh ReplicatedMergeTree replicas have different UUIDs on different nodes.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 7/9 (77.78%) | Lost baseline coverage: none · Uncovered code |
…plan-unknown-table Fix logical error when table is dropped before distributed plan task deserialization
Closes: #106906
Related: #106020
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
With
make_distributed_plan = 1, a table can be dropped concurrently between the coordinator serializing the query plan and a worker deserializing it. This is a reachable runtime condition, not an invariant violation, but the worker threwLOGICAL_ERROR, aborting the server in debug and sanitizer builds and bringing down stress tests since #106020.Now such a query fails with a regular
UNKNOWN_TABLEerror — the same behavior as parallel replicas with ReplicatedMergeTree, where a replica that receives a query for a concurrently dropped table returnsUNKNOWN_TABLEto the initiator.🤖 Generated with Claude Code
Version info
26.6.1.602