mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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 978b2f65aa
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
This commit is contained in:
@ -5615,7 +5615,9 @@ xact_redo(XLogReaderState *record)
|
||||
Assert(TransactionIdIsValid(parsed.twophase_xid));
|
||||
xact_redo_commit(&parsed, parsed.twophase_xid,
|
||||
record->EndRecPtr, XLogRecGetOrigin(record));
|
||||
RemoveTwoPhaseFile(parsed.twophase_xid, false);
|
||||
|
||||
/* Delete TwoPhaseState gxact entry and/or 2PC file. */
|
||||
PrepareRedoRemove(parsed.twophase_xid, false);
|
||||
}
|
||||
}
|
||||
else if (info == XLOG_XACT_ABORT || info == XLOG_XACT_ABORT_PREPARED)
|
||||
@ -5635,14 +5637,20 @@ xact_redo(XLogReaderState *record)
|
||||
{
|
||||
Assert(TransactionIdIsValid(parsed.twophase_xid));
|
||||
xact_redo_abort(&parsed, parsed.twophase_xid);
|
||||
RemoveTwoPhaseFile(parsed.twophase_xid, false);
|
||||
|
||||
/* Delete TwoPhaseState gxact entry and/or 2PC file. */
|
||||
PrepareRedoRemove(parsed.twophase_xid, false);
|
||||
}
|
||||
}
|
||||
else if (info == XLOG_XACT_PREPARE)
|
||||
{
|
||||
/* the record contents are exactly the 2PC file */
|
||||
RecreateTwoPhaseFile(XLogRecGetXid(record),
|
||||
XLogRecGetData(record), XLogRecGetDataLen(record));
|
||||
/*
|
||||
* Store xid and start/end pointers of the WAL record in
|
||||
* TwoPhaseState gxact entry.
|
||||
*/
|
||||
PrepareRedoAdd(XLogRecGetData(record),
|
||||
record->ReadRecPtr,
|
||||
record->EndRecPtr);
|
||||
}
|
||||
else if (info == XLOG_XACT_ASSIGNMENT)
|
||||
{
|
||||
|
Reference in New Issue
Block a user