mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Post-commit review fixes for 228c370868.
This commit fixes three issues: 1) When a disabled subscription is created with retain_dead_tuples set to true, the launcher is not woken up immediately, which may lead to delays in creating the conflict detection slot. Creating the conflict detection slot is essential even when the subscription is not enabled. This ensures that dead tuples are retained, which is necessary for accurately identifying the type of conflict during replication. 2) Conflict-related data was unnecessarily retained when the subscription does not have a table. 3) Conflict-relevant data could be prematurely removed before applying prepared transactions on the publisher that are in the commit critical section. This issue occurred because the backend executing COMMIT PREPARED was not accounted for during the computation of oldestXid in the commit phase on the publisher. As a result, the subscriber could advance the conflict slot's xmin without waiting for such COMMIT PREPARED transactions to complete. We fixed this issue by identifying prepared transactions that are in the commit critical section during computation of oldestXid in commit phase. Author: Zhijie Hou <houzj.fnst@fujitsu.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/OS9PR01MB16913DACB64E5721872AA5C02943BA@OS9PR01MB16913.jpnprd01.prod.outlook.com Discussion: https://postgr.es/m/OS9PR01MB16913F67856B0DA2A909788129400A@OS9PR01MB16913.jpnprd01.prod.outlook.com
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
|
||||
#include "access/timeline.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/twophase.h"
|
||||
#include "access/xact.h"
|
||||
#include "access/xlog_internal.h"
|
||||
#include "access/xlogreader.h"
|
||||
@@ -2719,6 +2720,7 @@ ProcessStandbyPSRequestMessage(void)
|
||||
{
|
||||
XLogRecPtr lsn = InvalidXLogRecPtr;
|
||||
TransactionId oldestXidInCommit;
|
||||
TransactionId oldestGXidInCommit;
|
||||
FullTransactionId nextFullXid;
|
||||
FullTransactionId fullOldestXidInCommit;
|
||||
WalSnd *walsnd = MyWalSnd;
|
||||
@@ -2746,6 +2748,16 @@ ProcessStandbyPSRequestMessage(void)
|
||||
* ones replicated.
|
||||
*/
|
||||
oldestXidInCommit = GetOldestActiveTransactionId(true, false);
|
||||
oldestGXidInCommit = TwoPhaseGetOldestXidInCommit();
|
||||
|
||||
/*
|
||||
* Update the oldest xid for standby transmission if an older prepared
|
||||
* transaction exists and is currently in commit phase.
|
||||
*/
|
||||
if (TransactionIdIsValid(oldestGXidInCommit) &&
|
||||
TransactionIdPrecedes(oldestGXidInCommit, oldestXidInCommit))
|
||||
oldestXidInCommit = oldestGXidInCommit;
|
||||
|
||||
nextFullXid = ReadNextFullTransactionId();
|
||||
fullOldestXidInCommit = FullTransactionIdFromAllowableAt(nextFullXid,
|
||||
oldestXidInCommit);
|
||||
|
||||
Reference in New Issue
Block a user