@@ -3106,9 +3106,11 @@ void MtmReleaseRecoverySlot(int nodeId)
3106
3106
*/
3107
3107
void MtmRollbackPreparedTransaction (int nodeId ,char const * gid )
3108
3108
{
3109
+ char state3pc [MAX_3PC_STATE_SIZE ];
3109
3110
XidStatus status = MtmExchangeGlobalTransactionStatus (gid ,TRANSACTION_STATUS_ABORTED );
3110
3111
MTM_LOG1 ("Abort prepared transaction %s status %s from node %d originId=%d" ,gid ,MtmTxnStatusMnem [status ],nodeId ,Mtm -> nodes [nodeId - 1 ].originId );
3111
- if (status == TRANSACTION_STATUS_UNKNOWN ) {
3112
+ if (status == TRANSACTION_STATUS_UNKNOWN || (status == TRANSACTION_STATUS_IN_PROGRESS && GetPreparedTransactionState (gid ,state3pc )))
3113
+ {
3112
3114
MTM_LOG1 ("PGLOGICAL_ABORT_PREPARED commit: gid=%s #2" ,gid );
3113
3115
MtmResetTransaction ();
3114
3116
StartTransactionCommand ();
@@ -3118,8 +3120,6 @@ void MtmRollbackPreparedTransaction(int nodeId, char const* gid)
3118
3120
CommitTransactionCommand ();
3119
3121
MtmEndSession (nodeId , true);
3120
3122
}else if (status == TRANSACTION_STATUS_IN_PROGRESS ) {
3121
- char state3pc [MAX_3PC_STATE_SIZE ];
3122
- Assert (!GetPreparedTransactionState (gid ,state3pc ));
3123
3123
MtmBeginSession (nodeId );
3124
3124
MtmLogAbortLogicalMessage (nodeId ,gid );
3125
3125
MtmEndSession (nodeId , true);