From a7580f444316bd7000c0c431b76af5b241174ab8 Mon Sep 17 00:00:00 2001 From: eaydingol Date: Tue, 12 Mar 2024 09:10:50 +0000 Subject: [PATCH] Print notification for each colocated shard. --- .../distributed/operations/shard_rebalancer.c | 31 +++++++++++++------ .../regress/expected/shard_rebalancer.out | 6 ++++ .../expected/single_node_enterprise.out | 6 ++++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/backend/distributed/operations/shard_rebalancer.c b/src/backend/distributed/operations/shard_rebalancer.c index 03dc4c1b8..1aae7c9bd 100644 --- a/src/backend/distributed/operations/shard_rebalancer.c +++ b/src/backend/distributed/operations/shard_rebalancer.c @@ -861,15 +861,28 @@ ExecutePlacementUpdates(List *placementUpdateList, Oid shardReplicationModeOid, foreach(placementUpdateCell, placementUpdateList) { PlacementUpdateEvent *placementUpdate = lfirst(placementUpdateCell); - ereport(NOTICE, (errmsg( - "%s shard %lu from %s:%u to %s:%u ...", - noticeOperation, - placementUpdate->shardId, - placementUpdate->sourceNode->workerName, - placementUpdate->sourceNode->workerPort, - placementUpdate->targetNode->workerName, - placementUpdate->targetNode->workerPort - ))); + List *colocatedUpdateList = GetColocatedRebalanceSteps(list_make1( + placementUpdate)); + ListCell *colocatedUpdateCell = NULL; + + /* + * Print the notification for each colocated shard as the placement of each colocated + * shard will be updated in the subsequent call. + */ + foreach(colocatedUpdateCell, colocatedUpdateList) + { + PlacementUpdateEvent *colocatedUpdate = lfirst(colocatedUpdateCell); + + ereport(NOTICE, (errmsg( + "%s shard %lu from %s:%u to %s:%u ...", + noticeOperation, + colocatedUpdate->shardId, + colocatedUpdate->sourceNode->workerName, + colocatedUpdate->sourceNode->workerPort, + colocatedUpdate->targetNode->workerName, + colocatedUpdate->targetNode->workerPort + ))); + } UpdateShardPlacement(placementUpdate, responsiveWorkerList, shardReplicationModeOid); MemoryContextReset(localContext); diff --git a/src/test/regress/expected/shard_rebalancer.out b/src/test/regress/expected/shard_rebalancer.out index 988fa68be..d3f9895b7 100644 --- a/src/test/regress/expected/shard_rebalancer.out +++ b/src/test/regress/expected/shard_rebalancer.out @@ -1776,6 +1776,8 @@ DETAIL: The balance improvement of 0.1xxxxx is lower than the improvement_thres NOTICE: Ignored 1 moves, all of which are shown in notices above HINT: If you do want these moves to happen, try changing improvement_threshold to a lower value than what it is now (0.5). NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... rebalance_table_shards --------------------------------------------------------------------- @@ -2805,6 +2807,8 @@ select 1 from citus_add_node('localhost', :worker_2_port); (1 row) select rebalance_table_shards(); +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... rebalance_table_shards --------------------------------------------------------------------- @@ -2905,6 +2909,8 @@ SELECT sh.logicalrelid, pl.nodeport -- but because the coordinator is not allowed for shards, rebalancer will distribute each colocation group to both workers select rebalance_table_shards(shard_transfer_mode:='block_writes'); NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... rebalance_table_shards --------------------------------------------------------------------- diff --git a/src/test/regress/expected/single_node_enterprise.out b/src/test/regress/expected/single_node_enterprise.out index 79f231864..ff4da4a59 100644 --- a/src/test/regress/expected/single_node_enterprise.out +++ b/src/test/regress/expected/single_node_enterprise.out @@ -244,6 +244,7 @@ DROP TABLE statement_replicated; -- and the other in block_writes SELECT rebalance_table_shards(max_shard_moves:=1); NOTICE: Stopped searching before we were out of moves. Please rerun the rebalancer after it's finished for a more optimal placement. +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... rebalance_table_shards --------------------------------------------------------------------- @@ -252,6 +253,8 @@ NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... SELECT rebalance_table_shards(shard_transfer_mode:='block_writes'); NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... rebalance_table_shards --------------------------------------------------------------------- @@ -417,6 +420,9 @@ SET citus.shard_replication_factor TO 1; SELECT master_drain_node('localhost', :master_port, shard_transfer_mode:='block_writes'); NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... +NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... NOTICE: Moving shard xxxxx from localhost:xxxxx to localhost:xxxxx ... master_drain_node ---------------------------------------------------------------------