mirror of https://github.com/citusdata/citus.git
Always throw errors on failure on critical connection in router executor
parent
1c36ade64d
commit
4ab8e87090
|
@ -1418,18 +1418,18 @@ SendQueryInSingleRowMode(MultiConnection *connection, char *query,
|
|||
|
||||
if (querySent == 0)
|
||||
{
|
||||
const bool raiseErrors = false;
|
||||
const bool raiseIfTransactionIsCritical = true;
|
||||
|
||||
HandleRemoteTransactionConnectionError(connection, raiseErrors);
|
||||
HandleRemoteTransactionConnectionError(connection, raiseIfTransactionIsCritical);
|
||||
return false;
|
||||
}
|
||||
|
||||
singleRowMode = PQsetSingleRowMode(connection->pgConn);
|
||||
if (singleRowMode == 0)
|
||||
{
|
||||
const bool raiseErrors = false;
|
||||
const bool raiseIfTransactionIsCritical = true;
|
||||
|
||||
HandleRemoteTransactionConnectionError(connection, raiseErrors);
|
||||
HandleRemoteTransactionConnectionError(connection, raiseIfTransactionIsCritical);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1571,6 +1571,10 @@ StoreQueryResult(CitusScanState *scanState, MultiConnection *connection,
|
|||
int category = 0;
|
||||
bool isConstraintViolation = false;
|
||||
|
||||
/*
|
||||
* Mark transaction as failed, but don't throw an error. This allows us
|
||||
* to give a more meaningful error message below.
|
||||
*/
|
||||
MarkRemoteTransactionFailed(connection, false);
|
||||
|
||||
/*
|
||||
|
@ -1581,7 +1585,8 @@ StoreQueryResult(CitusScanState *scanState, MultiConnection *connection,
|
|||
category = ERRCODE_TO_CATEGORY(ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION);
|
||||
isConstraintViolation = SqlStateMatchesCategory(sqlStateString, category);
|
||||
|
||||
if (isConstraintViolation || failOnError)
|
||||
if (isConstraintViolation || failOnError ||
|
||||
IsRemoteTransactionCritical(connection))
|
||||
{
|
||||
ReportResultError(connection, result, ERROR);
|
||||
}
|
||||
|
@ -1696,6 +1701,11 @@ ConsumeQueryResult(MultiConnection *connection, bool failOnError, int64 *rows)
|
|||
int category = 0;
|
||||
bool isConstraintViolation = false;
|
||||
|
||||
/*
|
||||
* Mark transaction as failed, but don't throw an error even if the
|
||||
* transaction is critical. This allows us to give a more meaningful
|
||||
* error message below.
|
||||
*/
|
||||
MarkRemoteTransactionFailed(connection, false);
|
||||
|
||||
/*
|
||||
|
@ -1706,7 +1716,8 @@ ConsumeQueryResult(MultiConnection *connection, bool failOnError, int64 *rows)
|
|||
category = ERRCODE_TO_CATEGORY(ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION);
|
||||
isConstraintViolation = SqlStateMatchesCategory(sqlStateString, category);
|
||||
|
||||
if (isConstraintViolation || failOnError)
|
||||
if (isConstraintViolation || failOnError ||
|
||||
IsRemoteTransactionCritical(connection))
|
||||
{
|
||||
ReportResultError(connection, result, ERROR);
|
||||
}
|
||||
|
|
|
@ -721,6 +721,19 @@ MarkRemoteTransactionCritical(struct MultiConnection *connection)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* IsRemoteTransactionCritical returns whether the remote transaction on
|
||||
* the given connection has been marked as critical.
|
||||
*/
|
||||
bool
|
||||
IsRemoteTransactionCritical(struct MultiConnection *connection)
|
||||
{
|
||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||
|
||||
return transaction->transactionCritical;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CloseRemoteTransaction handles closing a connection that, potentially, is
|
||||
* part of a coordinated transaction. This should only ever be called from
|
||||
|
|
|
@ -115,6 +115,7 @@ extern void HandleRemoteTransactionResultError(struct MultiConnection *connectio
|
|||
extern void MarkRemoteTransactionFailed(struct MultiConnection *connection,
|
||||
bool allowErrorPromotion);
|
||||
extern void MarkRemoteTransactionCritical(struct MultiConnection *connection);
|
||||
extern bool IsRemoteTransactionCritical(struct MultiConnection *connection);
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue