mirror of https://github.com/citusdata/citus.git
Remove "WarnAboutLeakedPreparedTransaction" function
We used to need WarnAboutLeakedPreparedTransaction() as we didn't have auto 2PC recovery. But, we long have 2PC recovery by https://github.com/citusdata/citus/pull/1574 So, we don't need anymore.pull/4474/head
parent
bcfc0aa4e9
commit
2fe158961b
|
@ -47,7 +47,6 @@ static void FinishRemoteTransactionSavepointRollback(MultiConnection *connection
|
||||||
SubTransactionId subId);
|
SubTransactionId subId);
|
||||||
|
|
||||||
static void Assign2PCIdentifier(MultiConnection *connection);
|
static void Assign2PCIdentifier(MultiConnection *connection);
|
||||||
static void WarnAboutLeakedPreparedTransaction(MultiConnection *connection, bool commit);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -215,7 +214,6 @@ StartRemoteTransactionCommit(MultiConnection *connection)
|
||||||
{
|
{
|
||||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||||
const bool raiseErrors = false;
|
const bool raiseErrors = false;
|
||||||
const bool isCommit = true;
|
|
||||||
|
|
||||||
/* can only commit if transaction is in progress */
|
/* can only commit if transaction is in progress */
|
||||||
Assert(transaction->transactionState != REMOTE_TRANS_NOT_STARTED);
|
Assert(transaction->transactionState != REMOTE_TRANS_NOT_STARTED);
|
||||||
|
@ -253,8 +251,6 @@ StartRemoteTransactionCommit(MultiConnection *connection)
|
||||||
if (!SendRemoteCommand(connection, command.data))
|
if (!SendRemoteCommand(connection, command.data))
|
||||||
{
|
{
|
||||||
HandleRemoteTransactionConnectionError(connection, raiseErrors);
|
HandleRemoteTransactionConnectionError(connection, raiseErrors);
|
||||||
|
|
||||||
WarnAboutLeakedPreparedTransaction(connection, isCommit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -286,7 +282,6 @@ FinishRemoteTransactionCommit(MultiConnection *connection)
|
||||||
{
|
{
|
||||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||||
const bool raiseErrors = false;
|
const bool raiseErrors = false;
|
||||||
const bool isCommit = true;
|
|
||||||
|
|
||||||
Assert(transaction->transactionState == REMOTE_TRANS_1PC_ABORTING ||
|
Assert(transaction->transactionState == REMOTE_TRANS_1PC_ABORTING ||
|
||||||
transaction->transactionState == REMOTE_TRANS_1PC_COMMITTING ||
|
transaction->transactionState == REMOTE_TRANS_1PC_COMMITTING ||
|
||||||
|
@ -318,7 +313,6 @@ FinishRemoteTransactionCommit(MultiConnection *connection)
|
||||||
{
|
{
|
||||||
ereport(WARNING, (errmsg("failed to commit transaction on %s:%d",
|
ereport(WARNING, (errmsg("failed to commit transaction on %s:%d",
|
||||||
connection->hostname, connection->port)));
|
connection->hostname, connection->port)));
|
||||||
WarnAboutLeakedPreparedTransaction(connection, isCommit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (transaction->transactionState == REMOTE_TRANS_1PC_ABORTING ||
|
else if (transaction->transactionState == REMOTE_TRANS_1PC_ABORTING ||
|
||||||
|
@ -358,7 +352,6 @@ StartRemoteTransactionAbort(MultiConnection *connection)
|
||||||
{
|
{
|
||||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
RemoteTransaction *transaction = &connection->remoteTransaction;
|
||||||
const bool raiseErrors = false;
|
const bool raiseErrors = false;
|
||||||
const bool isNotCommit = false;
|
|
||||||
|
|
||||||
Assert(transaction->transactionState != REMOTE_TRANS_NOT_STARTED);
|
Assert(transaction->transactionState != REMOTE_TRANS_NOT_STARTED);
|
||||||
|
|
||||||
|
@ -385,8 +378,6 @@ StartRemoteTransactionAbort(MultiConnection *connection)
|
||||||
if (!SendRemoteCommand(connection, command.data))
|
if (!SendRemoteCommand(connection, command.data))
|
||||||
{
|
{
|
||||||
HandleRemoteTransactionConnectionError(connection, raiseErrors);
|
HandleRemoteTransactionConnectionError(connection, raiseErrors);
|
||||||
|
|
||||||
WarnAboutLeakedPreparedTransaction(connection, isNotCommit);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -438,11 +429,7 @@ FinishRemoteTransactionAbort(MultiConnection *connection)
|
||||||
PGresult *result = GetRemoteCommandResult(connection, raiseErrors);
|
PGresult *result = GetRemoteCommandResult(connection, raiseErrors);
|
||||||
if (!IsResponseOK(result))
|
if (!IsResponseOK(result))
|
||||||
{
|
{
|
||||||
const bool isCommit = false;
|
|
||||||
|
|
||||||
HandleRemoteTransactionResultError(connection, result, raiseErrors);
|
HandleRemoteTransactionResultError(connection, result, raiseErrors);
|
||||||
|
|
||||||
WarnAboutLeakedPreparedTransaction(connection, isCommit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
@ -1403,35 +1390,3 @@ ParsePreparedTransactionName(char *preparedTransactionName,
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WarnAboutLeakedPreparedTransaction issues a WARNING explaining that a
|
|
||||||
* prepared transaction could not be committed or rolled back, and explains
|
|
||||||
* how to perform cleanup.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
WarnAboutLeakedPreparedTransaction(MultiConnection *connection, bool commit)
|
|
||||||
{
|
|
||||||
StringInfoData command;
|
|
||||||
RemoteTransaction *transaction = &connection->remoteTransaction;
|
|
||||||
|
|
||||||
initStringInfo(&command);
|
|
||||||
|
|
||||||
if (commit)
|
|
||||||
{
|
|
||||||
appendStringInfo(&command, "COMMIT PREPARED %s",
|
|
||||||
quote_literal_cstr(transaction->preparedName));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
appendStringInfo(&command, "ROLLBACK PREPARED %s",
|
|
||||||
quote_literal_cstr(transaction->preparedName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* log a warning so the user may abort the transaction later */
|
|
||||||
ereport(WARNING, (errmsg("failed to roll back prepared transaction '%s'",
|
|
||||||
transaction->preparedName),
|
|
||||||
errhint("Run \"%s\" on %s:%u",
|
|
||||||
command.data, connection->hostname, connection->port)));
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue