8000 ABORT PREPARED due to non-existent xact in apply worker failure is fine. · postgrespro/postgres_cluster@31495de · GitHub
[go: up one dir, main page]

Skip to content

Commit 31495de

Browse files
committed
ABORT PREPARED due to non-existent xact in apply worker failure is fine.
1 parent 576d589 commit 31495de

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/backend/replication/logical/worker.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,22 @@ apply_handle_rollback_prepared_txn(LogicalRepCommitData *commit_data)
592592
replorigin_session_origin_lsn = commit_data->end_lsn;
593593
replorigin_session_origin_timestamp = commit_data->committime;
594594

595-
/* FIXME: it is ok if xact is absent */
596-
FinishPreparedTransaction(commit_data->gid, false);
595+
/* It is ok if xact is absent, currently AP might came after ABORT */
596+
PG_TRY();
597+
{
598+
FinishPreparedTransaction(commit_data->gid, false);
599+
}
600+
PG_CATCH();
601+
{
602+
ErrorData *errdata = CopyErrorData();
603+
604+
/* re-throw if not 'xact absent' error */
605+
if (errdata->sqlerrcode != ERRCODE_UNDEFINED_OBJECT)
606+
{
607+
PG_RE_THROW();
608+
}
609+
}
610+
PG_END_TRY();
597611
CommitTransactionCommand();
598612
pgstat_report_stat(false);
599613

0 commit comments

Comments
 (0)
0