From cd8e41bb794b10bb5138fda8c9c546dd792157b6 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Tue, 10 Jan 2017 23:08:18 +0200 Subject: [PATCH] Fix CloseNodeConnections to actually close connections CloseNodeConnections() is supposed to close connections to a given node. However, before this commit it lacks to actually call PQFinish() on the connections. Using CloseConnection() handles closing and all other necessary actions. --- src/backend/distributed/connection/connection_management.c | 7 +------ src/test/regress/expected/multi_cluster_management.out | 2 ++ src/test/regress/sql/multi_cluster_management.sql | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/connection/connection_management.c b/src/backend/distributed/connection/connection_management.c index 7909e9d75..2ce448332 100644 --- a/src/backend/distributed/connection/connection_management.c +++ b/src/backend/distributed/connection/connection_management.c @@ -333,12 +333,7 @@ CloseNodeConnections(char *nodeName, int nodePort) MultiConnection *connection = dlist_container(MultiConnection, connectionNode, currentNode); - /* same for transaction state */ - CloseRemoteTransaction(connection); - CloseShardPlacementAssociation(connection); - - /* we leave the per-host entry alive */ - pfree(connection); + CloseConnection(connection); } } } diff --git a/src/test/regress/expected/multi_cluster_management.out b/src/test/regress/expected/multi_cluster_management.out index 7d191d13b..f0f3cb18e 100644 --- a/src/test/regress/expected/multi_cluster_management.out +++ b/src/test/regress/expected/multi_cluster_management.out @@ -121,6 +121,8 @@ SELECT master_get_active_worker_nodes(); (localhost,57637) (2 rows) +-- insert a row so that master_disable_node() exercises closing connections +INSERT INTO test_reference_table VALUES (1, '1'); -- try to disable a node with active placements see that node is removed -- observe that a notification is displayed SELECT master_disable_node('localhost', :worker_2_port); diff --git a/src/test/regress/sql/multi_cluster_management.sql b/src/test/regress/sql/multi_cluster_management.sql index 4e5e5ed2e..df020204f 100644 --- a/src/test/regress/sql/multi_cluster_management.sql +++ b/src/test/regress/sql/multi_cluster_management.sql @@ -45,6 +45,9 @@ SELECT shardid, shardstate, nodename, nodeport FROM pg_dist_shard_placement WHER SELECT master_remove_node('localhost', :worker_2_port); SELECT master_get_active_worker_nodes(); +-- insert a row so that master_disable_node() exercises closing connections +INSERT INTO test_reference_table VALUES (1, '1'); + -- try to disable a node with active placements see that node is removed -- observe that a notification is displayed SELECT master_disable_node('localhost', :worker_2_port);