diff --git a/src/backend/distributed/commands/dependencies.c b/src/backend/distributed/commands/dependencies.c index 50a6d4421..f7e021917 100644 --- a/src/backend/distributed/commands/dependencies.c +++ b/src/backend/distributed/commands/dependencies.c @@ -64,7 +64,8 @@ EnsureDependenciesExistOnAllNodes(const ObjectAddress *target) List *dependencyCommands = GetDependencyCreateDDLCommands(dependency); ddlCommands = list_concat(ddlCommands, dependencyCommands); - // TODO: Might add check for tables + /* TODO: Might add check for tables */ + /* create a new list with dependencies that actually created commands */ if (list_length(dependencyCommands) > 0) { @@ -243,17 +244,20 @@ GetDependencyCreateDDLCommands(const ObjectAddress *dependency) { /* skip table metadata creation when the Citus table is owned by an extension */ List *commandList = NIL; - List *tableDDLCommands = GetFullTableCreationCommands(relationId, WORKER_NEXTVAL_SEQUENCE_DEFAULTS); + List *tableDDLCommands = GetFullTableCreationCommands(relationId, + WORKER_NEXTVAL_SEQUENCE_DEFAULTS); TableDDLCommand *tableDDLCommand = NULL; foreach_ptr(tableDDLCommand, tableDDLCommands) { Assert(CitusIsA(tableDDLCommand, TableDDLCommand)); - commandList = lappend(commandList, GetTableDDLCommand(tableDDLCommand)); + commandList = lappend(commandList, GetTableDDLCommand( + tableDDLCommand)); } - // TODO: May need to move sequence dependencies to ActiveNode directly - List *sequenceDependencyCommandList = SequenceDependencyCommandList(dependency->objectId); + /* TODO: May need to move sequence dependencies to ActiveNode directly */ + List *sequenceDependencyCommandList = SequenceDependencyCommandList( + dependency->objectId); commandList = list_concat(commandList, sequenceDependencyCommandList); return commandList; @@ -265,6 +269,9 @@ GetDependencyCreateDDLCommands(const ObjectAddress *dependency) char *userName = GetUserNameFromId(GetUserId(), false); return DDLCommandsForSequence(dependency->objectId, userName); } + + /* if this relation is not supported, break to the error at the end */ + break; } case OCLASS_COLLATION: @@ -395,7 +402,9 @@ ReplicateAllDependenciesToNode(const char *nodeName, int nodePort) ddlCommands = lcons(DISABLE_DDL_PROPAGATION, ddlCommands); ddlCommands = lappend(ddlCommands, ENABLE_DDL_PROPAGATION); - SendMetadataCommandListToWorkerInCoordinatedTransaction(nodeName, nodePort, CitusExtensionOwnerName(), ddlCommands); + SendMetadataCommandListToWorkerInCoordinatedTransaction(nodeName, nodePort, + CitusExtensionOwnerName(), + ddlCommands); } diff --git a/src/backend/distributed/metadata/dependency.c b/src/backend/distributed/metadata/dependency.c index 0b3e4db56..962163ce6 100644 --- a/src/backend/distributed/metadata/dependency.c +++ b/src/backend/distributed/metadata/dependency.c @@ -677,11 +677,13 @@ SupportedDependencyByCitus(const ObjectAddress *address) */ if (relKind == RELKIND_COMPOSITE_TYPE || relKind == RELKIND_RELATION || - relKind == RELKIND_PARTITIONED_TABLE || // TODO: Should check for normal tables? + relKind == RELKIND_PARTITIONED_TABLE || /* TODO: Should check for normal tables? */ relKind == RELKIND_SEQUENCE) { return true; } + + return false; } default: diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index c4db122b9..9e4a8c201 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -1819,7 +1819,6 @@ CreateTableMetadataOnWorkers(Oid relationId) } - /* * SyncMetadataToNodes tries recreating the metadata snapshot in the * metadata workers that are out of sync. Returns the result of diff --git a/src/backend/distributed/metadata/node_metadata.c b/src/backend/distributed/metadata/node_metadata.c index 675543024..20dd584c9 100644 --- a/src/backend/distributed/metadata/node_metadata.c +++ b/src/backend/distributed/metadata/node_metadata.c @@ -248,7 +248,7 @@ citus_add_node(PG_FUNCTION_ARGS) if (!EnableDependencyCreation) { ereport(ERROR, (errmsg("citus.enable_object_propagation must be on to " - "add node"))); + "add node"))); } /* @@ -592,10 +592,10 @@ master_set_node_property(PG_FUNCTION_ARGS) /* * SetUpMultipleDistributedTableIntegrations set up the multiple integrations * including - * + * * (i) Foreign keys * (ii) Partionining hierarchy - * + * * on the given worker node. */ static void @@ -656,8 +656,10 @@ SetUpMultipleDistributedTableIntegrations(WorkerNode *workerNode) } char *currentUser = CurrentUserName(); - multipleTableIntegrationCommandList = lcons(DISABLE_DDL_PROPAGATION, multipleTableIntegrationCommandList); - multipleTableIntegrationCommandList = lappend(multipleTableIntegrationCommandList, ENABLE_DDL_PROPAGATION); + multipleTableIntegrationCommandList = lcons(DISABLE_DDL_PROPAGATION, + multipleTableIntegrationCommandList); + multipleTableIntegrationCommandList = lappend(multipleTableIntegrationCommandList, + ENABLE_DDL_PROPAGATION); SendMetadataCommandListToWorkerInCoordinatedTransaction(workerNode->workerName, workerNode->workerPort, currentUser, @@ -719,8 +721,10 @@ SetUpObjectMetadata(WorkerNode *workerNode) distributedObjectSyncCommandList); } - metadataSnapshotCommandList = lcons(DISABLE_DDL_PROPAGATION, metadataSnapshotCommandList); - metadataSnapshotCommandList = lappend(metadataSnapshotCommandList, ENABLE_DDL_PROPAGATION); + metadataSnapshotCommandList = lcons(DISABLE_DDL_PROPAGATION, + metadataSnapshotCommandList); + metadataSnapshotCommandList = lappend(metadataSnapshotCommandList, + ENABLE_DDL_PROPAGATION); char *currentUser = CurrentUserName(); SendMetadataCommandListToWorkerInCoordinatedTransaction(workerNode->workerName, @@ -830,15 +834,18 @@ ClearDistributedObjectsWithMetadataFromNode(WorkerNode *workerNode) List *detachPartitionCommandList = DetachPartitionCommandList(); clearDistTableInfoCommandList = list_concat(clearDistTableInfoCommandList, - detachPartitionCommandList); + detachPartitionCommandList); clearDistTableInfoCommandList = lappend(clearDistTableInfoCommandList, - REMOVE_ALL_CLUSTERED_TABLES_COMMAND); + REMOVE_ALL_CLUSTERED_TABLES_COMMAND); - clearDistTableInfoCommandList = lappend(clearDistTableInfoCommandList, DELETE_ALL_DISTRIBUTED_OBJECTS); + clearDistTableInfoCommandList = lappend(clearDistTableInfoCommandList, + DELETE_ALL_DISTRIBUTED_OBJECTS); - clearDistTableInfoCommandList = list_concat(list_make1(DISABLE_DDL_PROPAGATION),clearDistTableInfoCommandList); - clearDistTableInfoCommandList = list_concat(clearDistTableInfoCommandList, list_make1(ENABLE_DDL_PROPAGATION)); + clearDistTableInfoCommandList = list_concat(list_make1(DISABLE_DDL_PROPAGATION), + clearDistTableInfoCommandList); + clearDistTableInfoCommandList = list_concat(clearDistTableInfoCommandList, list_make1( + ENABLE_DDL_PROPAGATION)); char *currentUser = CurrentUserName(); SendMetadataCommandListToWorkerInCoordinatedTransaction(workerNode->workerName, @@ -932,9 +939,9 @@ PropagateNodeWideObjects(WorkerNode *newWorkerNode) /* send commands to new workers*/ SendMetadataCommandListToWorkerInCoordinatedTransaction(newWorkerNode->workerName, - newWorkerNode->workerPort, - CitusExtensionOwnerName(), - ddlCommands); + newWorkerNode->workerPort, + CitusExtensionOwnerName(), + ddlCommands); } } @@ -975,7 +982,7 @@ citus_activate_node(PG_FUNCTION_ARGS) if (!EnableDependencyCreation) { ereport(ERROR, (errmsg("citus.enable_object_propagation must be on to " - "activate node"))); + "activate node"))); } WorkerNode *workerNode = ModifiableWorkerNode(text_to_cstring(nodeNameText), @@ -1179,14 +1186,14 @@ ActivateNode(char *nodeName, int nodePort) { StartMetadataSyncToNode(nodeName, nodePort); - /* - * Since coordinator node already has both objects and related metadata - * we don't need to recreate them. - */ + /* + * Since coordinator node already has both objects and related metadata + * we don't need to recreate them. + */ if (workerNode->groupId != COORDINATOR_GROUP_ID) { - // TODO: Consider calling function below according to other states like primary/secondary - // Should we check syncMetadata always on as well? + /* TODO: Consider calling function below according to other states like primary/secondary */ + /* Should we check syncMetadata always on as well? */ ClearDistributedObjectsWithMetadataFromNode(workerNode); SetUpDistributedTableWithDependencies(workerNode); SetUpMultipleDistributedTableIntegrations(workerNode); @@ -1206,6 +1213,7 @@ ActivateNode(char *nodeName, int nodePort) return newWorkerNode->nodeId; } + /* * DetachPartitionCommandList returns list of DETACH commands to detach partitions * of all distributed tables. This function is used for detaching partitions in MX @@ -1242,7 +1250,8 @@ DetachPartitionCommandList(void) return NIL; } - detachPartitionCommandList = lcons(DISABLE_DDL_PROPAGATION, detachPartitionCommandList); + detachPartitionCommandList = lcons(DISABLE_DDL_PROPAGATION, + detachPartitionCommandList); /* * We probably do not need this but as an extra precaution, we are enabling