mirror of https://github.com/citusdata/citus.git
Create a new colocation properly after braking one
When braking a colocation, we need to create a new colocation group
record in pg_dist_colocation for the relation. It is not sufficient to
have a new colocationid value in pg_dist_partition only.
This patch also fixes a bug when deleting a colocation group if no
tables are left in it. Previously we passed a relation id as a parameter
to DeleteColocationGroupIfNoTablesBelong function, where we should have
passed a colocation id.
(cherry picked from commit c22547d221
)
release-11.0-hanefi
parent
57e8bb3891
commit
df50a2c0ea
|
@ -157,12 +157,11 @@ BreakColocation(Oid sourceRelationId)
|
|||
*/
|
||||
Relation pgDistColocation = table_open(DistColocationRelationId(), ExclusiveLock);
|
||||
|
||||
uint32 newColocationId = GetNextColocationId();
|
||||
bool localOnly = false;
|
||||
UpdateRelationColocationGroup(sourceRelationId, newColocationId, localOnly);
|
||||
uint32 oldColocationId = TableColocationId(sourceRelationId);
|
||||
CreateColocationGroupForRelation(sourceRelationId);
|
||||
|
||||
/* if there is not any remaining table in the colocation group, delete it */
|
||||
DeleteColocationGroupIfNoTablesBelong(sourceRelationId);
|
||||
/* if there is not any remaining table in the old colocation group, delete it */
|
||||
DeleteColocationGroupIfNoTablesBelong(oldColocationId);
|
||||
|
||||
table_close(pgDistColocation, NoLock);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue