Content-Length: 329986 | pFad | http://github.com/postgrespro/postgres_cluster/commit/b4a5fe836d6e4b60207fa1fee49cadcafdb45b61

5C Advance replorigen during prepare · postgrespro/postgres_cluster@b4a5fe8 · GitHub
Skip to content

Commit b4a5fe8

Browse files
committed
Advance replorigen during prepare
1 parent 6761fc9 commit b4a5fe8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/backend/access/transam/twophase.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,10 @@ EndPrepare(GlobalTransaction gxact)
10251025
xl_xact_origen xl_origen;
10261026
xl_xact_xinfo xl_xinfo;
10271027
uint8 info = XLOG_XACT_PREPARE;
1028+
bool replorigen;
1029+
1030+
replorigen = (replorigen_session_origen != InvalidRepOriginId &&
1031+
replorigen_session_origen != DoNotReplicateId);
10281032

10291033
/* Add the end sentinel to the list of 2PC records */
10301034
RegisterTwoPhaseRecord(TWOPHASE_RM_END_ID, 0,
@@ -1089,6 +1093,12 @@ EndPrepare(GlobalTransaction gxact)
10891093
XLogIncludeOrigin();
10901094

10911095
gxact->prepare_end_lsn = XLogInsert(RM_XACT_ID, info);
1096+
1097+
if (replorigen)
1098+
/* Move LSNs forward for this replication origen */
1099+
replorigen_session_advance(replorigen_session_origen_lsn,
1100+
XactLastRecEnd);
1101+
10921102
XLogFlush(gxact->prepare_end_lsn);
10931103

10941104
/* If we crash now, we have prepared: WAL replay will fix things */

src/backend/access/transam/xact.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5657,9 +5657,20 @@ xact_redo(XLogReaderState *record)
56575657
}
56585658
else if (info == XLOG_XACT_PREPARE)
56595659
{
5660+
xl_xact_parsed_prepare parsed;
5661+
5662+
ParsePrepareRecord(XLogRecGetXid(record), XLogRecGetData(record), &parsed);
5663+
56605664
/* the record contents are exactly the 2PC file */
56615665
RecreateTwoPhaseFile(XLogRecGetXid(record),
56625666
XLogRecGetData(record), XLogRecGetDataLen(record));
5667+
5668+
if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
5669+
{
5670+
/* recover apply progress */
5671+
replorigen_advance(XLogRecGetOrigin(record), parsed.origen_lsn,
5672+
record->EndRecPtr, false /* backward */ , false /* WAL */ );
5673+
}
56635674
}
56645675
else if (info == XLOG_XACT_ASSIGNMENT)
56655676
{

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/b4a5fe836d6e4b60207fa1fee49cadcafdb45b61

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy