mirror of https://github.com/citusdata/citus.git
Set placement to inactive on connection failure in COPY
parent
4476a7be81
commit
d0c76407b8
|
@ -834,7 +834,7 @@ OpenCopyConnections(CopyStmt *copyStatement, ShardConnections *shardConnections,
|
|||
bool stopOnFailure, bool useBinaryCopyFormat)
|
||||
{
|
||||
List *finalizedPlacementList = NIL;
|
||||
List *failedPlacementList = NIL;
|
||||
int failedPlacementCount = 0;
|
||||
ListCell *placementCell = NULL;
|
||||
List *connectionList = NULL;
|
||||
int64 shardId = shardConnections->shardId;
|
||||
|
@ -863,8 +863,6 @@ OpenCopyConnections(CopyStmt *copyStatement, ShardConnections *shardConnections,
|
|||
foreach(placementCell, finalizedPlacementList)
|
||||
{
|
||||
ShardPlacement *placement = (ShardPlacement *) lfirst(placementCell);
|
||||
char *nodeName = placement->nodeName;
|
||||
int nodePort = placement->nodePort;
|
||||
char *nodeUser = CurrentUserName();
|
||||
MultiConnection *connection = NULL;
|
||||
uint32 connectionFlags = FOR_DML;
|
||||
|
@ -877,12 +875,16 @@ OpenCopyConnections(CopyStmt *copyStatement, ShardConnections *shardConnections,
|
|||
{
|
||||
if (stopOnFailure)
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open connection to %s:%d",
|
||||
nodeName, nodePort)));
|
||||
ReportConnectionError(connection, ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportConnectionError(connection, WARNING);
|
||||
MarkRemoteTransactionFailed(connection, true);
|
||||
|
||||
failedPlacementList = lappend(failedPlacementList, placement);
|
||||
continue;
|
||||
failedPlacementCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -907,8 +909,7 @@ OpenCopyConnections(CopyStmt *copyStatement, ShardConnections *shardConnections,
|
|||
|
||||
PQclear(result);
|
||||
|
||||
/* failed placements will be invalidated by transaction machinery */
|
||||
failedPlacementList = lappend(failedPlacementList, placement);
|
||||
failedPlacementCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -917,9 +918,9 @@ OpenCopyConnections(CopyStmt *copyStatement, ShardConnections *shardConnections,
|
|||
}
|
||||
|
||||
/* if all placements failed, error out */
|
||||
if (list_length(failedPlacementList) == list_length(finalizedPlacementList))
|
||||
if (failedPlacementCount == list_length(finalizedPlacementList))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not find any active placements")));
|
||||
ereport(ERROR, (errmsg("could not connect to any active placements")));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -927,7 +928,7 @@ OpenCopyConnections(CopyStmt *copyStatement, ShardConnections *shardConnections,
|
|||
* never reach to this point. This is the case for reference tables and
|
||||
* copy from worker nodes.
|
||||
*/
|
||||
Assert(!stopOnFailure || list_length(failedPlacementList) == 0);
|
||||
Assert(!stopOnFailure || failedPlacementCount == 0);
|
||||
|
||||
shardConnections->connectionList = connectionList;
|
||||
|
||||
|
|
Loading…
Reference in New Issue