From 9b9d8e7abd875fabedc3b736ac82161757bf2e1f Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Thu, 12 Jan 2023 13:04:47 +0300 Subject: [PATCH] Use shard transfer UDFs with node ids for rebalancing --- .../distributed/operations/shard_rebalancer.c | 16 ++++++---------- src/test/regress/expected/shard_rebalancer.out | 8 ++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/backend/distributed/operations/shard_rebalancer.c b/src/backend/distributed/operations/shard_rebalancer.c index d7837cfda..dd9eb4a1f 100644 --- a/src/backend/distributed/operations/shard_rebalancer.c +++ b/src/backend/distributed/operations/shard_rebalancer.c @@ -2026,23 +2026,19 @@ UpdateShardPlacement(PlacementUpdateEvent *placementUpdateEvent, if (updateType == PLACEMENT_UPDATE_MOVE) { appendStringInfo(placementUpdateCommand, - "SELECT citus_move_shard_placement(%ld,%s,%u,%s,%u,%s)", + "SELECT citus_move_shard_placement(%ld,%u,%u,%s)", shardId, - quote_literal_cstr(sourceNode->workerName), - sourceNode->workerPort, - quote_literal_cstr(targetNode->workerName), - targetNode->workerPort, + sourceNode->nodeId, + targetNode->nodeId, quote_literal_cstr(shardTranferModeLabel)); } else if (updateType == PLACEMENT_UPDATE_COPY) { appendStringInfo(placementUpdateCommand, - "SELECT citus_copy_shard_placement(%ld,%s,%u,%s,%u,%s)", + "SELECT citus_copy_shard_placement(%ld,%u,%u,%s)", shardId, - quote_literal_cstr(sourceNode->workerName), - sourceNode->workerPort, - quote_literal_cstr(targetNode->workerName), - targetNode->workerPort, + sourceNode->nodeId, + targetNode->nodeId, quote_literal_cstr(shardTranferModeLabel)); } else diff --git a/src/test/regress/expected/shard_rebalancer.out b/src/test/regress/expected/shard_rebalancer.out index 84ba28402..413943ed9 100644 --- a/src/test/regress/expected/shard_rebalancer.out +++ b/src/test/regress/expected/shard_rebalancer.out @@ -221,7 +221,7 @@ NOTICE: issuing SET LOCAL citus.shard_count TO '4'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing SET LOCAL citus.shard_replication_factor TO '2'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT citus_copy_shard_placement(433101,'localhost',57637,'localhost',57638,'block_writes') +NOTICE: issuing SELECT citus_copy_shard_placement(433101,16,18,'block_writes') DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx @@ -244,7 +244,7 @@ NOTICE: issuing SET LOCAL citus.shard_count TO '4'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing SET LOCAL citus.shard_replication_factor TO '2'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT citus_copy_shard_placement(433102,'localhost',57638,'localhost',57637,'block_writes') +NOTICE: issuing SELECT citus_copy_shard_placement(433102,18,16,'block_writes') DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx @@ -267,7 +267,7 @@ NOTICE: issuing SET LOCAL citus.shard_count TO '4'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing SET LOCAL citus.shard_replication_factor TO '2'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT citus_copy_shard_placement(433103,'localhost',57637,'localhost',57638,'block_writes') +NOTICE: issuing SELECT citus_copy_shard_placement(433103,16,18,'block_writes') DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx @@ -290,7 +290,7 @@ NOTICE: issuing SET LOCAL citus.shard_count TO '4'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing SET LOCAL citus.shard_replication_factor TO '2'; DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing SELECT citus_copy_shard_placement(433104,'localhost',57638,'localhost',57637,'block_writes') +NOTICE: issuing SELECT citus_copy_shard_placement(433104,18,16,'block_writes') DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx