Thread: pgsql: Treat 2PC commit/abort the same as regular xacts in recovery.
Treat 2PC commit/abort the same as regular xacts in recovery. There were several oversights in recovery code where COMMIT/ABORT PREPARED records were ignored: * pg_last_xact_replay_timestamp() (wasn't updated for 2PC commits) * recovery_min_apply_delay (2PC commits were applied immediately) * recovery_target_xid (recovery would not stop if the XID used 2PC) The first of those was reported by Sergiy Zuban in bug #11032, analyzed by Tom Lane and Andres Freund. The bug was always there, but was masked before commit d19bd29f07aef9e508ff047d128a4046cc8bc1e2, because COMMIT PREPARED always created an extra regular transaction that was WAL-logged. Backpatch to all supported versions (older versions didn't have all the features and therefore didn't have all of the above bugs). Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/e74e0906fad5fcdcc807d4655cdc69dded5d58f2 Modified Files -------------- src/backend/access/transam/xlog.c | 60 ++++++++++++++++++++++++++++++++----- src/include/access/xact.h | 3 +- 2 files changed, 53 insertions(+), 10 deletions(-)
Heikki Linnakangas <heikki.linnakangas@iki.fi> writes: > Treat 2PC commit/abort the same as regular xacts in recovery. Looking at this again ... didn't you just break recoveryStopsBefore? ISTM the added line if (record_info == XLOG_XACT_COMMIT_PREPARED) needs to be else if (record_info == XLOG_XACT_COMMIT_PREPARED) As it stands, control will reach the "return false" for regular commit records. regards, tom lane
Re: pgsql: Treat 2PC commit/abort the same as regular xacts in recovery.
From
Heikki Linnakangas
Date:
On 07/29/2014 05:10 PM, Tom Lane wrote: > Heikki Linnakangas <heikki.linnakangas@iki.fi> writes: >> Treat 2PC commit/abort the same as regular xacts in recovery. > > Looking at this again ... didn't you just break recoveryStopsBefore? > ISTM the added line > > if (record_info == XLOG_XACT_COMMIT_PREPARED) > > needs to be > > else if (record_info == XLOG_XACT_COMMIT_PREPARED) > > As it stands, control will reach the "return false" for regular > commit records. Oops :-(. Fixed, thanks! - Heikki