From da133943e11f258d608100e653299ad98bf426b6 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Wed, 1 Apr 2026 18:16:26 +0300 Subject: [PATCH] Wait sync replication in critical section --- src/backend/access/transam/xact.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 053a200d9cb..9e99f4a567f 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -1520,16 +1520,6 @@ RecordTransactionCommit(void) TransactionIdAsyncCommitTree(xid, nchildren, children, XactLastRecEnd); } - /* - * If we entered a commit critical section, leave it now, and let - * checkpoints proceed. - */ - if (markXidCommitted) - { - MyProc->delayChkptFlags &= ~DELAY_CHKPT_START; - END_CRIT_SECTION(); - } - /* Compute latestXid while we have the child XIDs handy */ latestXid = TransactionIdLatest(xid, nchildren, children); @@ -1550,6 +1540,17 @@ RecordTransactionCommit(void) /* Reset XactLastRecEnd until the next transaction writes something */ XactLastRecEnd = 0; + + /* + * If we entered a commit critical section, leave it now, and let + * checkpoints proceed. + */ + if (markXidCommitted) + { + MyProc->delayChkptFlags &= ~DELAY_CHKPT_START; + END_CRIT_SECTION(); + } + cleanup: /* Clean up local data */ if (rels)