Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit15378c1

Browse files
Remove AELs from subxids correctly on standby
Issues relate only to subtransactions that hold AccessExclusiveLockswhen replayed on standby.Prior to PG10, aborting subtransactions that held anAccessExclusiveLock failed to release the lock until top level commit orabort.49bff53 fixed that.However,49bff53 also introduced a similar bug where subtransactioncommit would fail to release an AccessExclusiveLock, leaving the lock tobe removed sometimes early and sometimes late. This commit fixesthat bug also. Backpatch to PG10 needed.Tested by observation. Note need for multi-node isolationtester to improvetest coverage for this and other HS cases.Reported-by: Simon RiggsAuthor: Simon Riggs
1 parent1cfdb1c commit15378c1

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5602,12 +5602,10 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
56025602
/*
56035603
* Release locks, if any. We do this for both two phase and normal one
56045604
* phase transactions. In effect we are ignoring the prepare phase and
5605-
* just going straight to lock release. At commit we release all locks
5606-
* via their top-level xid only, so no need to provide subxact list,
5607-
* which will save time when replaying commits.
5605+
* just going straight to lock release.
56085606
*/
56095607
if (parsed->xinfo&XACT_XINFO_HAS_AE_LOCKS)
5610-
StandbyReleaseLockTree(xid,0,NULL);
5608+
StandbyReleaseLockTree(xid,parsed->nsubxacts,parsed->subxacts);
56115609
}
56125610

56135611
if (parsed->xinfo&XACT_XINFO_HAS_ORIGIN)

‎src/backend/storage/ipc/procarray.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
684684

685685
/*
686686
* Remove stale locks, if any.
687-
*
688-
* Locks are always assigned to the toplevel xid so we don't need to care
689-
* about subxcnt/subxids (and by extension not about ->suboverflowed).
690687
*/
691-
StandbyReleaseOldLocks(running->xcnt,running->xids);
688+
StandbyReleaseOldLocks(running->oldestRunningXid);
692689

693690
/*
694691
* If our snapshot is already valid, nothing else to do...

‎src/backend/storage/ipc/standby.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ StandbyReleaseAllLocks(void)
722722
*as long as they're not prepared transactions.
723723
*/
724724
void
725-
StandbyReleaseOldLocks(intnxids,TransactionId*xids)
725+
StandbyReleaseOldLocks(TransactionIdoldxid)
726726
{
727727
ListCell*cell,
728728
*prev,
@@ -741,26 +741,8 @@ StandbyReleaseOldLocks(int nxids, TransactionId *xids)
741741

742742
if (StandbyTransactionIdIsPrepared(lock->xid))
743743
remove= false;
744-
else
745-
{
746-
inti;
747-
boolfound= false;
748-
749-
for (i=0;i<nxids;i++)
750-
{
751-
if (lock->xid==xids[i])
752-
{
753-
found= true;
754-
break;
755-
}
756-
}
757-
758-
/*
759-
* If its not a running transaction, remove it.
760-
*/
761-
if (!found)
762-
remove= true;
763-
}
744+
elseif (TransactionIdPrecedes(lock->xid,oldxid))
745+
remove= true;
764746

765747
if (remove)
766748
{

‎src/include/storage/standby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern void StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid
5050
externvoidStandbyReleaseLockTree(TransactionIdxid,
5151
intnsubxids,TransactionId*subxids);
5252
externvoidStandbyReleaseAllLocks(void);
53-
externvoidStandbyReleaseOldLocks(intnxids,TransactionId*xids);
53+
externvoidStandbyReleaseOldLocks(TransactionIdoldxid);
5454

5555
#defineMinSizeOfXactRunningXacts offsetof(xl_running_xacts, xids)
5656

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp