From 379f2a9b3bad60e8c035c3028869410addb9e714 Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Thu, 22 Jul 2021 16:17:11 +0200 Subject: [PATCH] Move pg_dist_object commandlist generation to a function --- .../distributed/metadata/metadata_sync.c | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index 35d5aa3d6..42d1fee4f 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -83,6 +83,7 @@ static List * GetDistributedTableDDLEvents(Oid relationId); static char * LocalGroupIdUpdateCommand(int32 groupId); static void UpdateDistNodeBoolAttr(const char *nodeName, int32 nodePort, int attrNum, bool value); +static List * DistributedObjectSyncCommandList(); static List * SequenceDependencyCommandList(Oid relationId); static char * TruncateTriggerCreateCommand(Oid relationId); static char * SchemaOwnerName(Oid objectId); @@ -508,7 +509,8 @@ MetadataCreateCommands() * * Instead we rely on the initial sync of the pg_dist_object * contents at the end of this function. By inserting it here - * locally, it will become part of that sync automatically. + * locally, it will become part of that the list of commands that + * DistributedObjectSyncCommandList returns automatically. * * The only downside of this approach is that it won't be synced to * other metadata nodes than the current one. This should not be a @@ -608,6 +610,20 @@ MetadataCreateCommands() shardCreateCommandList); } + metadataSnapshotCommandList = list_concat( + metadataSnapshotCommandList, + DistributedObjectSyncCommandList()); + + + return metadataSnapshotCommandList; +} + + +static List * +DistributedObjectSyncCommandList() +{ + List *commandList = NIL; + HeapTuple pgDistObjectTup = NULL; Relation pgDistObjectRel = table_open(DistObjectRelationId(), AccessShareLock); @@ -637,15 +653,12 @@ MetadataCreateCommands() &address, distributionArgumentIndexIsNull ? NULL : &distributionArgumentIndex, colocationIdIsNull ? NULL : &colocationId); - metadataSnapshotCommandList = lappend(metadataSnapshotCommandList, - workerMetadataUpdateCommand); + commandList = lappend(commandList, workerMetadataUpdateCommand); } systable_endscan(pgDistObjectScan); relation_close(pgDistObjectRel, AccessShareLock); - - - return metadataSnapshotCommandList; + return commandList; }