From 728bd991c3c4389fb39c45dcb0fe57e4a1dccd71 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Tue, 4 Apr 2017 15:56:56 -0400 Subject: Speedup 2PC recovery by skipping two phase state files in normal path 2PC state info held in shmem at PREPARE, then cleaned at COMMIT PREPARED/ABORT PREPARED, avoiding writing/fsyncing any state information to disk in the normal path, greatly enhancing replay speed. Prepared transactions that live past one checkpoint redo horizon will be written to disk as now. Similar conceptually to 978b2f65aa1262eb4ecbf8b3785cb1b9cf4db78e and building upon the infrastructure created by that commit. Authors, in equal measure: Stas Kelvich, Nikhil Sontakke and Michael Paquier Discussion: https://postgr.es/m/CAMGcDxf8Bn9ZPBBJZba9wiyQq-Qk5uqq=VjoMnRnW5s+fKST3w@mail.gmail.com --- src/backend/access/transam/xlog.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5d58f0983cf..287b3b13799 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6696,6 +6696,16 @@ StartupXLOG(void) */ restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI); + /* + * Before running in recovery, scan pg_twophase and fill in its status + * to be able to work on entries generated by redo. Doing a scan before + * taking any recovery action has the merit to discard any 2PC files that + * are newer than the first record to replay, saving from any conflicts at + * replay. This avoids as well any subsequent scans when doing recovery + * of the on-disk two-phase data. + */ + restoreTwoPhaseData(); + lastFullPageWrites = checkPoint.fullPageWrites; RedoRecPtr = XLogCtl->RedoRecPtr = XLogCtl->Insert.RedoRecPtr = checkPoint.redo; -- cgit v1.2.3