From 6843ad8e917a45e93b18110ce289d1398c40987b Mon Sep 17 00:00:00 2001 From: Brian Cloutier Date: Thu, 26 Jan 2017 17:00:42 +0300 Subject: [PATCH] Fix bug where router executor sends query to failed connections --- .../distributed/executor/multi_router_executor.c | 12 ++++++++++++ src/test/regress/expected/multi_router_planner.out | 3 --- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/executor/multi_router_executor.c b/src/backend/distributed/executor/multi_router_executor.c index 9b5a93a23..ceed971b2 100644 --- a/src/backend/distributed/executor/multi_router_executor.c +++ b/src/backend/distributed/executor/multi_router_executor.c @@ -733,6 +733,18 @@ ExecuteSingleModifyTask(QueryDesc *queryDesc, Task *task, bool failOnError = false; int64 currentAffectedTupleCount = 0; + if (connection->remoteTransaction.transactionFailed) + { + /* + * If GetModifyConnections failed to send BEGIN this connection will have + * been marked as failed, and should not have any more commands sent to + * it! Skip it for now, at the bottom of this method we call + * MarkFailedShardPlacements() to ensure future statements will not use this + * placement. + */ + continue; + } + queryOK = SendQueryInSingleRowMode(connection, queryString, paramListInfo); if (!queryOK) { diff --git a/src/test/regress/expected/multi_router_planner.out b/src/test/regress/expected/multi_router_planner.out index 43fe205b3..f4e998290 100644 --- a/src/test/regress/expected/multi_router_planner.out +++ b/src/test/regress/expected/multi_router_planner.out @@ -2073,9 +2073,6 @@ INSERT INTO failure_test VALUES (1, 1); WARNING: connection error: localhost:57638 DETAIL: no connection to the server -WARNING: connection error: localhost:57638 -DETAIL: no connection to the server - SELECT shardid, shardstate, nodename, nodeport FROM pg_dist_shard_placement WHERE shardid IN ( SELECT shardid FROM pg_dist_shard