diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index da5ba51a1d0..89b2fb66f8b 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5648,6 +5648,7 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) bool stopsHere; uint8 record_info; TimestampTz recordXtime; + TransactionId recordXid; char recordRPName[MAXFNAMELEN]; /* We only consider stopping at COMMIT, ABORT or RESTORE POINT records */ @@ -5660,6 +5661,15 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) recordXactCommitData = (xl_xact_commit *) XLogRecGetData(record); recordXtime = recordXactCommitData->xact_time; + recordXid = record->xl_xid; + } + else if (record->xl_rmid == RM_XACT_ID && record_info == XLOG_XACT_COMMIT_PREPARED) + { + xl_xact_commit_prepared *recordXactCommitData; + + recordXactCommitData = (xl_xact_commit_prepared *) XLogRecGetData(record); + recordXtime = recordXactCommitData->crec.xact_time; + recordXid = recordXactCommitData->xid; } else if (record->xl_rmid == RM_XACT_ID && record_info == XLOG_XACT_ABORT) { @@ -5667,6 +5677,15 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) recordXactAbortData = (xl_xact_abort *) XLogRecGetData(record); recordXtime = recordXactAbortData->xact_time; + recordXid = record->xl_xid; + } + else if (record->xl_rmid == RM_XACT_ID && record_info == XLOG_XACT_ABORT_PREPARED) + { + xl_xact_abort_prepared *recordXactAbortData; + + recordXactAbortData = (xl_xact_abort_prepared *) XLogRecGetData(record); + recordXtime = recordXactAbortData->arec.xact_time; + recordXid = recordXactAbortData->xid; } else if (record->xl_rmid == RM_XLOG_ID && record_info == XLOG_RESTORE_POINT) { @@ -5674,6 +5693,7 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) recordRestorePointData = (xl_restore_point *) XLogRecGetData(record); recordXtime = recordRestorePointData->rp_time; + recordXid = InvalidTransactionId; strlcpy(recordRPName, recordRestorePointData->rp_name, MAXFNAMELEN); } else @@ -5702,7 +5722,7 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) * they complete. A higher numbered xid will complete before you about * 50% of the time... */ - stopsHere = (record->xl_xid == recoveryTargetXid); + stopsHere = (recordXid == recoveryTargetXid); if (stopsHere) *includeThis = recoveryTargetInclusive; } @@ -5737,11 +5757,12 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) if (stopsHere) { - recoveryStopXid = record->xl_xid; + recoveryStopXid = recordXid; recoveryStopTime = recordXtime; recoveryStopAfter = *includeThis; - if (record_info == XLOG_XACT_COMMIT) + if (record_info == XLOG_XACT_COMMIT || + record_info == XLOG_XACT_COMMIT_PREPARED) { if (recoveryStopAfter) ereport(LOG, @@ -5754,7 +5775,8 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } - else if (record_info == XLOG_XACT_ABORT) + else if (record_info == XLOG_XACT_ABORT || + record_info == XLOG_XACT_ABORT_PREPARED) { if (recoveryStopAfter) ereport(LOG, diff --git a/src/include/access/xact.h b/src/include/access/xact.h index cb440d41f14..b95c0b16512 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -165,8 +165,7 @@ typedef struct xl_xact_abort /* * COMMIT_PREPARED and ABORT_PREPARED are identical to COMMIT/ABORT records * except that we have to store the XID of the prepared transaction explicitly - * --- the XID in the record header will be for the transaction doing the - * COMMIT PREPARED or ABORT PREPARED command. + * --- the XID in the record header will be invalid. */ typedef struct xl_xact_commit_prepared