sync objects without coordinated tx

metadata_sync_final
Onder Kalaci 2022-12-01 15:49:54 +01:00
parent 77ef777d53
commit 386a1f7889
1 changed files with 15 additions and 6 deletions

View File

@ -100,7 +100,7 @@ static void InsertPlaceholderCoordinatorRecord(void);
static void InsertNodeRow(int nodeid, char *nodename, int32 nodeport, NodeMetadata static void InsertNodeRow(int nodeid, char *nodename, int32 nodeport, NodeMetadata
*nodeMetadata); *nodeMetadata);
static void DeleteNodeRow(char *nodename, int32 nodeport); static void DeleteNodeRow(char *nodename, int32 nodeport);
static void SyncDistributedObjectsToNodeList(List *workerNodeList); static void SyncDistributedObjectsInOutsideTransaction(List *workerNodeList);
static void UpdateLocalGroupIdOnNode(WorkerNode *workerNode); static void UpdateLocalGroupIdOnNode(WorkerNode *workerNode);
static void SyncPgDistTableMetadataToNodeList(List *nodeList); static void SyncPgDistTableMetadataToNodeList(List *nodeList);
static void BuildInterTableRelationships(List *connectionList, List **commandList); static void BuildInterTableRelationships(List *connectionList, List **commandList);
@ -775,12 +775,16 @@ PropagateNodeWideObjects(List *connectionList, List **commandList)
if (alterRoleSetCommands != NIL) if (alterRoleSetCommands != NIL)
{ {
ExecuteRemoteCommandInConnectionList(connectionList, DISABLE_DDL_PROPAGATION);
char *command = NULL; char *command = NULL;
foreach_ptr(command, alterRoleSetCommands) foreach_ptr(command, alterRoleSetCommands)
{ {
ExecuteRemoteCommandInConnectionList(connectionList, command); ExecuteRemoteCommandInConnectionList(connectionList, command);
} }
ExecuteRemoteCommandInConnectionList(connectionList, ENABLE_DDL_PROPAGATION);
/* the caller is interested in collecting the commands */ /* the caller is interested in collecting the commands */
if (commandList != NULL) if (commandList != NULL)
{ {
@ -807,8 +811,9 @@ PropagateNodeWideObjects(List *connectionList, List **commandList)
* - Inter relation between those shell tables * - Inter relation between those shell tables
* - Node wide objects * - Node wide objects
* *
* We also update the local group id here, as handling sequence dependencies * If the optional commandList is provided, the function fills
* requires it. * the list. But note that the list can be huge due to
* partitioning, so use the list cautiously.
*/ */
void void
SyncDistributedObjects(List *workerNodeList, List **commandList) SyncDistributedObjects(List *workerNodeList, List **commandList)
@ -848,7 +853,8 @@ SyncDistributedObjects(List *workerNodeList, List **commandList)
/* /*
* SyncDistributedObjectsToNodeList sync the distributed objects to the node. It includes * SyncDistributedObjectsInOutsideTransaction sync the distributed
* objects to the nodes. It includes
* - All dependencies (e.g., types, schemas, sequences) * - All dependencies (e.g., types, schemas, sequences)
* - All shell distributed table * - All shell distributed table
* - Inter relation between those shell tables * - Inter relation between those shell tables
@ -857,7 +863,7 @@ SyncDistributedObjects(List *workerNodeList, List **commandList)
* since all the dependencies should be present in the coordinator already. * since all the dependencies should be present in the coordinator already.
*/ */
static void static void
SyncDistributedObjectsToNodeList(List *workerNodeList) SyncDistributedObjectsInOutsideTransaction(List *workerNodeList)
{ {
if (workerNodeList == NIL) if (workerNodeList == NIL)
{ {
@ -1234,8 +1240,11 @@ ActivateNodeList(List *nodeList)
* Sync distributed objects first. We must sync distributed objects before * Sync distributed objects first. We must sync distributed objects before
* replicating reference tables to the remote node, as reference tables may * replicating reference tables to the remote node, as reference tables may
* need such objects. * need such objects.
*
* Given that object creation is idempotent, we can afford to run them
* outside the transaction.
*/ */
SyncDistributedObjectsToNodeList(nodeToSyncMetadata); SyncDistributedObjectsInOutsideTransaction(nodeToSyncMetadata);
/* /*
* Sync node metadata. We must sync node metadata before syncing table * Sync node metadata. We must sync node metadata before syncing table