Fix metadata sync failure with domain types in non-public schemas
When adding a worker node to a Citus cluster, metadata synchronization would fail if any distributed table used a DOMAIN type defined in a non-public schema as its distribution column. The error occurred because the colocation metadata command tried to cast a schema-qualified type name to regtype before the schema existed on the worker.
Problem: During metadata synchronization, SendColocationMetadataCommands() would generate SQL like:
WITH colocation_group_data (..., distributioncolumntype, ...) AS (
VALUES (..., '"prepared statements".test_key'::regtype, ...)
)
The ::regtype cast happened immediately in the VALUES clause, causing PostgreSQL to try resolving the type before the query executed. Since SendColocationMetadataCommands() runs before SendDependencyCreationCommands(), the schema and domain didn't exist on the worker yet, resulting in: ERROR: schema "prepared statements" does not exist
Solution: Modified the metadata sync to defer type resolution using a LEFT JOIN pattern, similar to how collations are handled.
Test case and expected output updates are also part of the commit
Fixes #8191
Codecov Report
:x: Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 88.93%. Comparing base (662b724) to head (21ccbf7).
Additional details and impacted files
@@ Coverage Diff @@
## main #8363 +/- ##
==========================================
- Coverage 88.95% 88.93% -0.02%
==========================================
Files 287 287
Lines 63151 63176 +25
Branches 7942 7946 +4
==========================================
+ Hits 56176 56187 +11
- Misses 4667 4676 +9
- Partials 2308 2313 +5
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.