mirror of https://github.com/citusdata/citus.git
Relax assertion on transaction rollback failure (#2052)
In case a failure happens when a transaction is rollbacked, we used to hit an assertion for ensuring there is no pending activity on the connection. However, that's not true after the changes in #2031. Thus, we've replaced the assertion with a more generic function call to consume any pending activity, if exists.pull/1997/head
parent
24659a97dc
commit
ebb8f902c8
|
@ -418,34 +418,30 @@ void
|
||||||
FinishRemoteTransactionAbort(MultiConnection *connection)
|
FinishRemoteTransactionAbort(MultiConnection *connection)
|
||||||
{
|
{
|
||||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||||
PGresult *result = NULL;
|
const bool raiseErrors = false;
|
||||||
const bool dontRaiseErrors = false;
|
|
||||||
const bool isNotCommit = false;
|
|
||||||
|
|
||||||
result = GetRemoteCommandResult(connection, dontRaiseErrors);
|
|
||||||
|
|
||||||
if (!IsResponseOK(result))
|
|
||||||
{
|
|
||||||
ReportResultError(connection, result, WARNING);
|
|
||||||
MarkRemoteTransactionFailed(connection, dontRaiseErrors);
|
|
||||||
|
|
||||||
if (transaction->transactionState == REMOTE_TRANS_2PC_ABORTING)
|
if (transaction->transactionState == REMOTE_TRANS_2PC_ABORTING)
|
||||||
{
|
{
|
||||||
WarnAboutLeakedPreparedTransaction(connection, isNotCommit);
|
PGresult *result = GetRemoteCommandResult(connection, raiseErrors);
|
||||||
}
|
if (!IsResponseOK(result))
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ereport(WARNING,
|
const bool isCommit = false;
|
||||||
(errmsg("failed to abort 1PC transaction \"%s\" on %s:%d",
|
WarnAboutLeakedPreparedTransaction(connection, isCommit);
|
||||||
transaction->preparedName, connection->hostname,
|
|
||||||
connection->port)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
}
|
||||||
|
|
||||||
result = GetRemoteCommandResult(connection, dontRaiseErrors);
|
/*
|
||||||
Assert(!result);
|
* Try to consume results of any in-progress commands. In the 1PC case
|
||||||
|
* this is also where we consume the result of the ROLLBACK.
|
||||||
|
*
|
||||||
|
* If we don't succeed the connection will be in a bad state, so we close it.
|
||||||
|
*/
|
||||||
|
if (!ClearResults(connection, raiseErrors))
|
||||||
|
{
|
||||||
|
ShutdownConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
transaction->transactionState = REMOTE_TRANS_ABORTED;
|
transaction->transactionState = REMOTE_TRANS_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue