Skip to content

Commit cd0ceba

Browse files
Always SnapshotResetXmin() during ClearTransaction()
Avoid corner cases during 2PC with 6bad580
1 parent 3217327 commit cd0ceba

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/backend/access/transam/xact.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2640,7 +2640,7 @@ CleanupTransaction(void)
26402640
* do abort cleanup processing
26412641
*/
26422642
AtCleanup_Portals(); /* now safe to release portal memory */
2643-
AtEOXact_Snapshot(false, false); /* and release the transaction's snapshots */
2643+
AtEOXact_Snapshot(false, true); /* and release the transaction's snapshots */
26442644

26452645
CurrentResourceOwner = NULL; /* and resource owner */
26462646
if (TopTransactionResourceOwner)

src/backend/utils/time/snapmgr.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ AtSubAbort_Snapshot(int level)
10511051
* Snapshot manager's cleanup function for end of transaction
10521052
*/
10531053
void
1054-
AtEOXact_Snapshot(bool isCommit, bool isPrepare)
1054+
AtEOXact_Snapshot(bool isCommit, bool resetXmin)
10551055
{
10561056
/*
10571057
* In transaction-snapshot mode we must release our privately-managed
@@ -1137,16 +1137,15 @@ AtEOXact_Snapshot(bool isCommit, bool isPrepare)
11371137
FirstSnapshotSet = false;
11381138

11391139
/*
1140-
* During normal commit and abort processing, we call
1141-
* ProcArrayEndTransaction() or ProcArrayClearTransaction() to
1142-
* reset the PgXact->xmin. That call happens prior to the call to
1143-
* AtEOXact_Snapshot(), so we need not touch xmin here at all,
1144-
* accept when we are preparing a transaction.
1140+
* During normal commit processing, we call
1141+
* ProcArrayEndTransaction() to reset the PgXact->xmin. That call
1142+
* happens prior to the call to AtEOXact_Snapshot(), so we need
1143+
* not touch xmin here at all.
11451144
*/
1146-
if (isPrepare)
1145+
if (resetXmin)
11471146
SnapshotResetXmin();
11481147

1149-
Assert(isPrepare || MyPgXact->xmin == 0);
1148+
Assert(resetXmin || MyPgXact->xmin == 0);
11501149
}
11511150

11521151

src/include/utils/snapmgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner);
8585

8686
extern void AtSubCommit_Snapshot(int level);
8787
extern void AtSubAbort_Snapshot(int level);
88-
extern void AtEOXact_Snapshot(bool isCommit, bool isPrepare);
88+
extern void AtEOXact_Snapshot(bool isCommit, bool resetXmin);
8989

9090
extern void ImportSnapshot(const char *idstr);
9191
extern bool XactHasExportedSnapshots(void);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy