Commit f5099d8
committed
Disallow colocating tables when collations don't match
- No need to make any changes for the following UDFs:
- update_distributed_table_colocation()/create_distributed_table_concurrently()
These are already checking whether collations of distribution keys match.
- ALTER TABLE .. ALTER COLUMN .. TYPE .. COLLATE ..
We already don't allow changing the collation of a distribution column.
- The following UDFs are fixed with this commit:
These UDFs were not explicitly checking whether collation of the distribution
keys of two distributed tables match, however, we were catching this via
EnsurePartitionMetadataIsSane() when syncing metadata. And this incorrectly
caused allowing to colocate two such distributed tables in a single-node setup
as we don't have any nodes to sync metadata there. In such cases, we would only
become aware of the situation **when adding a new node to the cluster etc.**.
Otherwise, i.e., if we already had more than one nodes in the cluster, we were
seeing this error while Citus is syncing metadata for the new / altered distributed
table, which wasn't too bad but not ideal too:
```sql
ERROR: cannot colocate tables test_a_tbl_2 and test_a_tbl_1
DETAIL: Distribution column collations don't match for test_a_tbl_2 and test_a_tbl_1.
CONTEXT: while executing command on localhost:9701
```
- create_distributed_table()
To fix that, now EnsureTableCanBeColocatedWith() calls EnsureColumnTypeEquality()
to perform necessary checks, which already ensures collation match.
And to do that, now EnsureTableCanBeColocatedWith() has to accept distributionColumn
Var as an argument (to be passed into EnsureColumnTypeEquality()), so now it doesn't
have to accept distributionColumnType separately, so refactor accordingly.
And to provide distributionColumn Var to EnsureTableCanBeColocatedWith(), similarly
the call sites of the function also need to have distributionColumn Var, like
FindColocateWithColocationId(). And now that FindColocateWithColocationId() accepts
distributionColumn Var, it doesn't have to accept distributionColumnType and
distributionColumnCollation separately, so refactor accordingly.
Plus, now this UDF also correctly records the colocation groups with the correct
distribution column collations.
- alter_distributed_table()
Make sure to check column collations.
- Also, now citus_finish_citus_upgrade() automatically fixes such colocation groups when
executed after upgrading to Citus 14.
This also helps removing the last alternative test output for
upgrade_citus_finish_citus_upgrade. This is because, the recent change made in
citus_finish_citus_upgrade() to automatically fix such colocation groups results in
updating last_upgrade_version in pg_dist_node_metadata when upgrading to Citus 14,
so the notice message in the mentioned test is now gone, so we don't anymore need to
have an alternative output for that test.1 parent b30ae94 commit f5099d8
File tree
28 files changed
+973
-86
lines changed- src
- backend/distributed
- commands
- sql
- downgrades
- udfs
- citus_finish_citus_upgrade
- fix_pre_citus14_colocation_group_collation_mismatches
- utils
- include/distributed
- test/regress
- expected
- sql
28 files changed
+973
-86
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2111 | 2111 | | |
2112 | 2112 | | |
2113 | 2113 | | |
2114 | | - | |
| 2114 | + | |
2115 | 2115 | | |
2116 | 2116 | | |
2117 | 2117 | | |
| |||
2122 | 2122 | | |
2123 | 2123 | | |
2124 | 2124 | | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
2125 | 2142 | | |
2126 | 2143 | | |
2127 | 2144 | | |
| |||
Lines changed: 9 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
535 | | - | |
536 | 534 | | |
537 | 535 | | |
538 | 536 | | |
| |||
547 | 545 | | |
548 | 546 | | |
549 | 547 | | |
550 | | - | |
551 | | - | |
| 548 | + | |
552 | 549 | | |
553 | 550 | | |
554 | 551 | | |
| |||
697 | 694 | | |
698 | 695 | | |
699 | 696 | | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | 697 | | |
710 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
711 | 703 | | |
712 | | - | |
| 704 | + | |
713 | 705 | | |
714 | 706 | | |
715 | 707 | | |
| |||
1993 | 1985 | | |
1994 | 1986 | | |
1995 | 1987 | | |
| 1988 | + | |
1996 | 1989 | | |
1997 | 1990 | | |
1998 | 1991 | | |
1999 | | - | |
| 1992 | + | |
2000 | 1993 | | |
2001 | 1994 | | |
2002 | 1995 | | |
| |||
2011 | 2004 | | |
2012 | 2005 | | |
2013 | 2006 | | |
2014 | | - | |
2015 | | - | |
| 2007 | + | |
2016 | 2008 | | |
2017 | 2009 | | |
2018 | 2010 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| |||
Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 79 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
0 commit comments