diff --git a/src/backend/distributed/operations/worker_shard_copy.c b/src/backend/distributed/operations/worker_shard_copy.c index a90c74ef9..9239caffb 100644 --- a/src/backend/distributed/operations/worker_shard_copy.c +++ b/src/backend/distributed/operations/worker_shard_copy.c @@ -70,7 +70,7 @@ static void ShardCopyDestReceiverStartup(DestReceiver *dest, int operation, TupleDesc inputTupleDescriptor); static void ShardCopyDestReceiverShutdown(DestReceiver *destReceiver); static void ShardCopyDestReceiverDestroy(DestReceiver *destReceiver); -static bool CanUseLocalCopy(uint64 destinationNodeId); +static bool CanUseLocalCopy(uint32_t destinationNodeId); static StringInfo ConstructShardCopyStatement(List *destinationShardFullyQualifiedName, bool useBinaryFormat); @@ -81,10 +81,10 @@ static void LocalCopyToShard(ShardCopyDestReceiver *copyDest, CopyOutState static void ConnectToRemoteAndStartCopy(ShardCopyDestReceiver *copyDest); static bool -CanUseLocalCopy(uint64 destinationNodeId) +CanUseLocalCopy(uint32_t destinationNodeId) { /* If destination node is same as source, use local copy */ - return GetLocalNodeId() == destinationNodeId; + return GetLocalNodeId() == (int32) destinationNodeId; } diff --git a/src/test/regress/expected/citus_split_shard_by_split_points.out b/src/test/regress/expected/citus_split_shard_by_split_points.out index 8adbb5f69..2d008dc24 100644 --- a/src/test/regress/expected/citus_split_shard_by_split_points.out +++ b/src/test/regress/expected/citus_split_shard_by_split_points.out @@ -91,7 +91,6 @@ SELECT COUNT(*) FROM colocated_dist_table; -- END: Load data into tables. -- BEGIN : Display current state. --- TODO(niupre): Can we refactor this to be a function? SELECT shard.shardid, logicalrelid, shardminvalue, shardmaxvalue, nodename, nodeport FROM pg_dist_shard AS shard INNER JOIN pg_dist_placement placement ON shard.shardid = placement.shardid @@ -241,7 +240,6 @@ SELECT citus_move_shard_placement(8981007, 'localhost', :worker_1_port, 'localho -- END : Move a shard post split. -- BEGIN : Display current state. --- TODO(niupre): Can we refactor this to be a function? SELECT shard.shardid, logicalrelid, shardminvalue, shardmaxvalue, nodename, nodeport FROM pg_dist_shard AS shard INNER JOIN pg_dist_placement placement ON shard.shardid = placement.shardid diff --git a/src/test/regress/expected/multi_cluster_management.out b/src/test/regress/expected/multi_cluster_management.out index cb3fe3a5d..1ac2c4965 100644 --- a/src/test/regress/expected/multi_cluster_management.out +++ b/src/test/regress/expected/multi_cluster_management.out @@ -1258,3 +1258,40 @@ SELECT bool_and(hasmetadata) AND bool_and(metadatasynced) FROM pg_dist_node WHER t (1 row) +-- Remove extra nodes added, this causes GetLocalNodeId() to behave incorrectly in other tests. +SELECT master_remove_node('localhost', 8887); + master_remove_node +--------------------------------------------------------------------- + +(1 row) + +SELECT master_remove_node('localhost', 9995); + master_remove_node +--------------------------------------------------------------------- + +(1 row) + +SELECT master_remove_node('localhost', 9992); + master_remove_node +--------------------------------------------------------------------- + +(1 row) + +SELECT master_remove_node('localhost', 9998); + master_remove_node +--------------------------------------------------------------------- + +(1 row) + +SELECT master_remove_node('localhost', 9997); + master_remove_node +--------------------------------------------------------------------- + +(1 row) + +SELECT master_remove_node('localhost', 8888); + master_remove_node +--------------------------------------------------------------------- + +(1 row) + diff --git a/src/test/regress/sql/citus_split_shard_by_split_points.sql b/src/test/regress/sql/citus_split_shard_by_split_points.sql index 8d618c3c5..7448a488a 100644 --- a/src/test/regress/sql/citus_split_shard_by_split_points.sql +++ b/src/test/regress/sql/citus_split_shard_by_split_points.sql @@ -67,7 +67,6 @@ SELECT COUNT(*) FROM colocated_dist_table; -- END: Load data into tables. -- BEGIN : Display current state. --- TODO(niupre): Can we refactor this to be a function? SELECT shard.shardid, logicalrelid, shardminvalue, shardmaxvalue, nodename, nodeport FROM pg_dist_shard AS shard INNER JOIN pg_dist_placement placement ON shard.shardid = placement.shardid @@ -148,7 +147,6 @@ SELECT citus_move_shard_placement(8981007, 'localhost', :worker_1_port, 'localho -- END : Move a shard post split. -- BEGIN : Display current state. --- TODO(niupre): Can we refactor this to be a function? SELECT shard.shardid, logicalrelid, shardminvalue, shardmaxvalue, nodename, nodeport FROM pg_dist_shard AS shard INNER JOIN pg_dist_placement placement ON shard.shardid = placement.shardid diff --git a/src/test/regress/sql/multi_cluster_management.sql b/src/test/regress/sql/multi_cluster_management.sql index 6d9b9c589..3d78f1382 100644 --- a/src/test/regress/sql/multi_cluster_management.sql +++ b/src/test/regress/sql/multi_cluster_management.sql @@ -511,3 +511,11 @@ SELECT start_metadata_sync_to_all_nodes(); -- verify that at the end of this file, all primary nodes have metadata synced SELECT bool_and(hasmetadata) AND bool_and(metadatasynced) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary'; + +-- Remove extra nodes added, this causes GetLocalNodeId() to behave incorrectly in other tests. +SELECT master_remove_node('localhost', 8887); +SELECT master_remove_node('localhost', 9995); +SELECT master_remove_node('localhost', 9992); +SELECT master_remove_node('localhost', 9998); +SELECT master_remove_node('localhost', 9997); +SELECT master_remove_node('localhost', 8888);