mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Rethink the delay-checkpoint-end mechanism in the back-branches.
The back-patch of commit bbace5697d had
the unfortunate effect of changing the layout of PGPROC in the
back-branches, which could break extensions. This happened because it
changed the delayChkpt from type bool to type int. So, change it back,
and add a new bool delayChkptEnd field instead. The new field should
fall within what used to be padding space within the struct, and so
hopefully won't cause any extensions to break.
Per report from Markus Wanner and discussion with Tom Lane and others.
Patch originally by me, somewhat revised by Markus Wanner per a
suggestion from Michael Paquier. A very similar patch was developed
by Kyotaro Horiguchi, but I failed to see the email in which that was
posted before writing one of my own.
Discussion: http://postgr.es/m/CA+Tgmoao-kUD9c5nG5sub3F7tbo39+cdr8jKaOVEs_1aBWcJ3Q@mail.gmail.com
Discussion: http://postgr.es/m/20220406.164521.17171257901083417.horikyota.ntt@gmail.com
This commit is contained in:
@@ -476,8 +476,9 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
|
||||
}
|
||||
pgxact->xid = xid;
|
||||
pgxact->xmin = InvalidTransactionId;
|
||||
pgxact->delayChkpt = 0;
|
||||
pgxact->delayChkpt = false;
|
||||
pgxact->vacuumFlags = 0;
|
||||
proc->delayChkptEnd = false;
|
||||
proc->pid = 0;
|
||||
proc->databaseId = databaseid;
|
||||
proc->roleId = owner;
|
||||
@@ -1175,8 +1176,8 @@ EndPrepare(GlobalTransaction gxact)
|
||||
|
||||
START_CRIT_SECTION();
|
||||
|
||||
Assert((MyPgXact->delayChkpt & DELAY_CHKPT_START) == 0);
|
||||
MyPgXact->delayChkpt |= DELAY_CHKPT_START;
|
||||
Assert(!MyPgXact->delayChkpt);
|
||||
MyPgXact->delayChkpt = true;
|
||||
|
||||
XLogBeginInsert();
|
||||
for (record = records.head; record != NULL; record = record->next)
|
||||
@@ -1219,7 +1220,7 @@ EndPrepare(GlobalTransaction gxact)
|
||||
* checkpoint starting after this will certainly see the gxact as a
|
||||
* candidate for fsyncing.
|
||||
*/
|
||||
MyPgXact->delayChkpt &= ~DELAY_CHKPT_START;
|
||||
MyPgXact->delayChkpt = false;
|
||||
|
||||
/*
|
||||
* Remember that we have this GlobalTransaction entry locked for us. If
|
||||
@@ -2353,8 +2354,8 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
START_CRIT_SECTION();
|
||||
|
||||
/* See notes in RecordTransactionCommit */
|
||||
Assert((MyPgXact->delayChkpt & DELAY_CHKPT_START) == 0);
|
||||
MyPgXact->delayChkpt |= DELAY_CHKPT_START;
|
||||
Assert(!MyPgXact->delayChkpt);
|
||||
MyPgXact->delayChkpt = true;
|
||||
|
||||
/*
|
||||
* Emit the XLOG commit record. Note that we mark 2PC commits as
|
||||
@@ -2402,7 +2403,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
TransactionIdCommitTree(xid, nchildren, children);
|
||||
|
||||
/* Checkpoint can proceed now */
|
||||
MyPgXact->delayChkpt &= ~DELAY_CHKPT_START;
|
||||
MyPgXact->delayChkpt = false;
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user