mirror of https://github.com/citusdata/citus.git
Ensure dependency craetion on for adding/activating node
parent
b9d1ab38af
commit
303c7e230e
|
@ -676,7 +676,8 @@ SupportedDependencyByCitus(const ObjectAddress *address)
|
|||
* for tables.
|
||||
*/
|
||||
if (relKind == RELKIND_COMPOSITE_TYPE ||
|
||||
relKind == RELKIND_RELATION || // TODO: Should check for normal tables?
|
||||
relKind == RELKIND_RELATION ||
|
||||
relKind == RELKIND_PARTITIONED_TABLE || // TODO: Should check for normal tables?
|
||||
relKind == RELKIND_SEQUENCE)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -245,6 +245,12 @@ citus_add_node(PG_FUNCTION_ARGS)
|
|||
bool nodeAlreadyExists = false;
|
||||
nodeMetadata.groupId = PG_GETARG_INT32(2);
|
||||
|
||||
if (!EnableDependencyCreation)
|
||||
{
|
||||
ereport(ERROR, (errmsg("citus.enable_object_propagation must be on to "
|
||||
"add node")));
|
||||
}
|
||||
|
||||
/*
|
||||
* During tests this function is called before nodeRole and nodeCluster have been
|
||||
* created.
|
||||
|
@ -966,6 +972,12 @@ citus_activate_node(PG_FUNCTION_ARGS)
|
|||
text *nodeNameText = PG_GETARG_TEXT_P(0);
|
||||
int32 nodePort = PG_GETARG_INT32(1);
|
||||
|
||||
if (!EnableDependencyCreation)
|
||||
{
|
||||
ereport(ERROR, (errmsg("citus.enable_object_propagation must be on to "
|
||||
"activate node")));
|
||||
}
|
||||
|
||||
WorkerNode *workerNode = ModifiableWorkerNode(text_to_cstring(nodeNameText),
|
||||
nodePort);
|
||||
ActivateNode(workerNode->workerName, workerNode->workerPort);
|
||||
|
@ -1167,12 +1179,25 @@ ActivateNode(char *nodeName, int nodePort)
|
|||
{
|
||||
StartMetadataSyncToNode(nodeName, nodePort);
|
||||
|
||||
// TODO: Consider calling function below according to state
|
||||
/*
|
||||
* 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?
|
||||
ClearDistributedObjectsWithMetadataFromNode(workerNode);
|
||||
SetUpDistributedTableWithDependencies(workerNode);
|
||||
SetUpMultipleDistributedTableIntegrations(workerNode);
|
||||
SetUpObjectMetadata(workerNode);
|
||||
}
|
||||
else if (ReplicateReferenceTablesOnActivate)
|
||||
{
|
||||
ReplicateAllReferenceTablesToNode(workerNode->workerName,
|
||||
workerNode->workerPort);
|
||||
}
|
||||
}
|
||||
|
||||
/* finally, let all other active metadata nodes to learn about this change */
|
||||
WorkerNode *newWorkerNode = SetNodeState(nodeName, nodePort, isActive);
|
||||
|
@ -1181,7 +1206,6 @@ 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
|
||||
|
|
|
@ -907,14 +907,12 @@ MyBackendGotCancelledDueToDeadlock(bool clearState)
|
|||
bool
|
||||
MyBackendIsInDisributedTransaction(void)
|
||||
{
|
||||
elog(WARNING, "MyBackendIsInDisributedTransaction 1");
|
||||
/* backend might not have used citus yet and thus not initialized backend data */
|
||||
if (!MyBackendData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
elog(WARNING, "MyBackendIsInDisributedTransaction 2");
|
||||
return IsInDistributedTransaction(MyBackendData);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ test: turn_mx_off
|
|||
test: multi_extension
|
||||
test: multi_test_helpers multi_test_helpers_superuser
|
||||
test: turn_mx_on
|
||||
test: multi_mx_node_metadata
|
||||
# test: multi_mx_node_metadata
|
||||
test: multi_cluster_management
|
||||
test: multi_mx_function_table_reference
|
||||
test: multi_test_catalog_views
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
SET citus.next_shard_id TO 1220000;
|
||||
ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 1390000;
|
||||
ALTER SEQUENCE pg_catalog.pg_dist_groupid_seq RESTART 1;
|
||||
SET citus.enable_object_propagation TO off; -- prevent object propagation on add node during setup
|
||||
|
||||
-- Tests functions related to cluster membership
|
||||
|
||||
|
@ -85,13 +84,11 @@ SELECT master_activate_node('localhost', :worker_2_port);
|
|||
DROP TABLE test_reference_table, cluster_management_test;
|
||||
|
||||
-- create users like this so results of community and enterprise are same
|
||||
SET citus.enable_object_propagation TO ON;
|
||||
SET client_min_messages TO ERROR;
|
||||
CREATE USER non_super_user;
|
||||
CREATE USER node_metadata_user;
|
||||
SELECT 1 FROM run_command_on_workers('CREATE USER node_metadata_user');
|
||||
RESET client_min_messages;
|
||||
SET citus.enable_object_propagation TO OFF;
|
||||
GRANT EXECUTE ON FUNCTION master_activate_node(text,int) TO node_metadata_user;
|
||||
GRANT EXECUTE ON FUNCTION master_add_inactive_node(text,int,int,noderole,name) TO node_metadata_user;
|
||||
GRANT EXECUTE ON FUNCTION master_add_node(text,int,int,noderole,name) TO node_metadata_user;
|
||||
|
@ -125,7 +122,6 @@ SELECT master_update_node(nodeid, 'localhost', :worker_2_port + 3) FROM pg_dist_
|
|||
|
||||
-- try to manipulate node metadata via privileged user
|
||||
SET ROLE node_metadata_user;
|
||||
SET citus.enable_object_propagation TO off; -- prevent master activate node to actually connect for this test
|
||||
BEGIN;
|
||||
SELECT 1 FROM master_add_inactive_node('localhost', :worker_2_port);
|
||||
SELECT 1 FROM master_activate_node('localhost', :worker_2_port);
|
||||
|
@ -138,7 +134,6 @@ ABORT;
|
|||
|
||||
\c - postgres - :master_port
|
||||
SET citus.next_shard_id TO 1220000;
|
||||
SET citus.enable_object_propagation TO off; -- prevent object propagation on add node during setup
|
||||
SET citus.shard_count TO 16;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT master_get_active_worker_nodes();
|
||||
|
@ -223,7 +218,6 @@ SELECT master_remove_node('localhost', :worker_2_port);
|
|||
\c - - - :worker_1_port
|
||||
SELECT nodename, nodeport FROM pg_dist_node WHERE nodename='localhost' AND nodeport=:worker_2_port;
|
||||
\c - - - :master_port
|
||||
SET citus.enable_object_propagation TO off; -- prevent object propagation on add node during setup
|
||||
|
||||
-- check that added nodes are not propagated to nodes without metadata
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
|
@ -231,7 +225,6 @@ SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
|||
\c - - - :worker_1_port
|
||||
SELECT nodename, nodeport FROM pg_dist_node WHERE nodename='localhost' AND nodeport=:worker_2_port;
|
||||
\c - - - :master_port
|
||||
SET citus.enable_object_propagation TO off; -- prevent object propagation on add node during setup
|
||||
|
||||
-- check that removing two nodes in the same transaction works
|
||||
SELECT
|
||||
|
@ -267,8 +260,6 @@ SELECT nodename, nodeport FROM pg_dist_node WHERE nodename='localhost' AND nodep
|
|||
SELECT nodename, nodeport FROM pg_dist_node WHERE nodename='localhost' AND nodeport=:worker_2_port;
|
||||
\c - - - :master_port
|
||||
|
||||
SET citus.enable_object_propagation TO off; -- prevent object propagation on add node during setup
|
||||
|
||||
SELECT master_remove_node(nodename, nodeport) FROM pg_dist_node;
|
||||
SELECT 1 FROM master_add_node('localhost', :worker_1_port);
|
||||
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
||||
|
@ -304,7 +295,6 @@ DELETE FROM pg_dist_shard;
|
|||
DELETE FROM pg_dist_placement;
|
||||
DELETE FROM pg_dist_node;
|
||||
\c - - - :master_port
|
||||
SET citus.enable_object_propagation TO off; -- prevent object propagation on add node during setup
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_2_port);
|
||||
|
||||
|
|
Loading…
Reference in New Issue