Merge pull request #1762 from citusdata/check_connection_status

Check connection status before using it
pull/1764/head
Metin Döşlü 2017-11-06 15:50:37 +02:00 committed by GitHub
commit 5984e7f009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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;