From 1efa301adaea5cfb0d352f96086fa743ecce7059 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 11 Jan 2017 02:56:30 +0200 Subject: [PATCH] Copy on reference tables should never mark placements invalid This commit ensures that COPY does not mark any placement of reference's state as INVALID in case of an error. --- src/backend/distributed/commands/multi_copy.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index c3c1aaf1b..96bbdbdfe 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -563,8 +563,15 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag) &shardConnectionsFound); if (!shardConnectionsFound) { + bool stopOnFailure = false; + + if (cacheEntry->partitionMethod == DISTRIBUTE_BY_NONE) + { + stopOnFailure = true; + } + /* open connections and initiate COPY on shard placements */ - OpenCopyTransactions(copyStatement, shardConnections, false, + OpenCopyTransactions(copyStatement, shardConnections, stopOnFailure, copyOutState->binary); /* send copy binary headers to shard placements */ @@ -598,7 +605,8 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag) /* close the COPY input on all shard placements */ EndRemoteCopy(connectionList, true); - if (MultiShardCommitProtocol == COMMIT_PROTOCOL_2PC) + if (MultiShardCommitProtocol == COMMIT_PROTOCOL_2PC || + cacheEntry->replicationModel == REPLICATION_MODEL_2PC) { PrepareRemoteTransactions(connectionList); } @@ -1051,7 +1059,8 @@ OpenCopyTransactions(CopyStmt *copyStatement, ShardConnections *shardConnections /* * If stopOnFailure is true, we just error out and code execution should - * never reach to this point. This is the case for copy from worker nodes. + * never reach to this point. This is the case for reference tables and + * copy from worker nodes. */ Assert(!stopOnFailure || list_length(failedPlacementList) == 0);