From d796f5cfb6f2824b5952bd9cd0fc057b7eb69708 Mon Sep 17 00:00:00 2001 From: Jimmy Yih Date: Mon, 29 Jun 2020 16:01:21 -0700 Subject: [PATCH] Handle distributed commit WAL records for various recovery features To allow experimentation of various Postgres recovery features, we must handle distributed commit WAL records similarly to commit and commit prepared WAL records. This will allow the standby master segment to utilize the recovery features. The mirror segments already get handled since they use the regular commit and commit prepared WAL records. With this change, the standby master segment will be able to properly output a value for a pg_last_xact_replay_timestamp() call (while in hot standby), have delayed WAL replay, and use PITR/archive recovery settings such as recovery_target_time and recovery_target_xid. --- src/backend/access/transam/xlog.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d880dd910e..d9a98ccff6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5637,7 +5637,8 @@ getRecordTimestamp(XLogReaderState *record, TimestampTz *recordXtime) return true; } if (rmid == RM_XACT_ID && (xact_info == XLOG_XACT_COMMIT || - xact_info == XLOG_XACT_COMMIT_PREPARED)) + xact_info == XLOG_XACT_COMMIT_PREPARED || + xact_info == XLOG_XACT_DISTRIBUTED_COMMIT)) { *recordXtime = ((xl_xact_commit *) XLogRecGetData(record))->xact_time; return true; @@ -5705,7 +5706,8 @@ recoveryStopsBefore(XLogReaderState *record) xact_info = XLogRecGetInfo(record) & XLOG_XACT_OPMASK; - if (xact_info == XLOG_XACT_COMMIT) + if (xact_info == XLOG_XACT_COMMIT || + xact_info == XLOG_XACT_DISTRIBUTED_COMMIT) { isCommit = true; recordXid = XLogRecGetXid(record); @@ -5864,7 +5866,8 @@ recoveryStopsAfter(XLogReaderState *record) if (xact_info == XLOG_XACT_COMMIT || xact_info == XLOG_XACT_COMMIT_PREPARED || xact_info == XLOG_XACT_ABORT || - xact_info == XLOG_XACT_ABORT_PREPARED) + xact_info == XLOG_XACT_ABORT_PREPARED || + xact_info == XLOG_XACT_DISTRIBUTED_COMMIT) { TransactionId recordXid; @@ -5915,7 +5918,8 @@ recoveryStopsAfter(XLogReaderState *record) recoveryStopName[0] = '\0'; if (xact_info == XLOG_XACT_COMMIT || - xact_info == XLOG_XACT_COMMIT_PREPARED) + xact_info == XLOG_XACT_COMMIT_PREPARED || + xact_info == XLOG_XACT_DISTRIBUTED_COMMIT) { ereport(LOG, (errmsg("recovery stopping after commit of transaction %u, time %s", @@ -6039,7 +6043,8 @@ recoveryApplyDelay(XLogReaderState *record) xact_info = XLogRecGetInfo(record) & XLOG_XACT_OPMASK; if (xact_info != XLOG_XACT_COMMIT && - xact_info != XLOG_XACT_COMMIT_PREPARED) + xact_info != XLOG_XACT_COMMIT_PREPARED && + xact_info != XLOG_XACT_DISTRIBUTED_COMMIT) return false; if (!getRecordTimestamp(record, &xtime)) -- GitLab