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-12.0-hanefi
parent
db8e12f418
commit
2105c20344
|
@ -174,12 +174,11 @@ BreakColocation(Oid sourceRelationId)
|
||||||
*/
|
*/
|
||||||
Relation pgDistColocation = table_open(DistColocationRelationId(), ExclusiveLock);
|
Relation pgDistColocation = table_open(DistColocationRelationId(), ExclusiveLock);
|
||||||
|
|
||||||
uint32 newColocationId = GetNextColocationId();
|
uint32 oldColocationId = TableColocationId(sourceRelationId);
|
||||||
bool localOnly = false;
|
CreateColocationGroupForRelation(sourceRelationId);
|
||||||
UpdateRelationColocationGroup(sourceRelationId, newColocationId, localOnly);
|
|
||||||
|
|
||||||
/* if there is not any remaining table in the colocation group, delete it */
|
/* if there is not any remaining table in the old colocation group, delete it */
|
||||||
DeleteColocationGroupIfNoTablesBelong(sourceRelationId);
|
DeleteColocationGroupIfNoTablesBelong(oldColocationId);
|
||||||
|
|
||||||
table_close(pgDistColocation, NoLock);
|
table_close(pgDistColocation, NoLock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue