diff --git a/src/backend/distributed/connection/remote_commands.c b/src/backend/distributed/connection/remote_commands.c index accd7f833..662fdb555 100644 --- a/src/backend/distributed/connection/remote_commands.c +++ b/src/backend/distributed/connection/remote_commands.c @@ -424,7 +424,7 @@ SendRemoteCommandParams(MultiConnection *connection, const char *command, * Don't try to send command if connection is entirely gone * (PQisnonblocking() would crash). */ - if (!pgConn) + if (!pgConn || PQstatus(pgConn) != CONNECTION_OK) { return 0; } @@ -457,7 +457,7 @@ SendRemoteCommand(MultiConnection *connection, const char *command) * Don't try to send command if connection is entirely gone * (PQisnonblocking() would crash). */ - if (!pgConn) + if (!pgConn || PQstatus(pgConn) != CONNECTION_OK) { return 0; } diff --git a/src/test/regress/expected/multi_replicate_reference_table.out b/src/test/regress/expected/multi_replicate_reference_table.out index 184c1885e..f38bb46b7 100644 --- a/src/test/regress/expected/multi_replicate_reference_table.out +++ b/src/test/regress/expected/multi_replicate_reference_table.out @@ -713,6 +713,12 @@ SELECT 1 FROM master_add_node('localhost', :worker_2_port); 1 (1 row) +-- test adding an invalid node while we have reference tables to replicate +-- set client message level to ERROR to suppress OS-dependent host name resolution warnings +SET client_min_messages to ERROR; +SELECT master_add_node('invalid-node-name', 9999); +ERROR: failure on connection marked as essential: invalid-node-name:9999 +SET client_min_messages to DEFAULT; -- drop unnecassary tables DROP TABLE initially_not_replicated_reference_table; -- reload pg_dist_shard_placement table diff --git a/src/test/regress/expected/multi_router_planner.out b/src/test/regress/expected/multi_router_planner.out index 6a1fa2f5f..50f6a8da8 100644 --- a/src/test/regress/expected/multi_router_planner.out +++ b/src/test/regress/expected/multi_router_planner.out @@ -2151,7 +2151,7 @@ GRANT INSERT ON ALL TABLES IN SCHEMA public TO router_user; BEGIN; INSERT INTO failure_test VALUES (1, 1); WARNING: connection error: localhost:57638 -DETAIL: no connection to the server +DETAIL: FATAL: role "router_user" does not exist SELECT shardid, shardstate, nodename, nodeport FROM pg_dist_shard_placement WHERE shardid IN ( SELECT shardid FROM pg_dist_shard @@ -2169,7 +2169,7 @@ SELECT shardid, shardstate, nodename, nodeport FROM pg_dist_shard_placement ROLLBACK; INSERT INTO failure_test VALUES (2, 1); WARNING: connection error: localhost:57638 -DETAIL: no connection to the server +DETAIL: FATAL: role "router_user" does not exist SELECT shardid, shardstate, nodename, nodeport FROM pg_dist_shard_placement WHERE shardid IN ( SELECT shardid FROM pg_dist_shard diff --git a/src/test/regress/sql/multi_replicate_reference_table.sql b/src/test/regress/sql/multi_replicate_reference_table.sql index 84b2f8c23..38becb491 100644 --- a/src/test/regress/sql/multi_replicate_reference_table.sql +++ b/src/test/regress/sql/multi_replicate_reference_table.sql @@ -457,6 +457,13 @@ ORDER BY 1,4,5; -- this should have no effect SELECT 1 FROM master_add_node('localhost', :worker_2_port); +-- test adding an invalid node while we have reference tables to replicate +-- set client message level to ERROR to suppress OS-dependent host name resolution warnings +SET client_min_messages to ERROR; +SELECT master_add_node('invalid-node-name', 9999); + +SET client_min_messages to DEFAULT; + -- drop unnecassary tables DROP TABLE initially_not_replicated_reference_table;