Commit cd0cebaf authored by Simon Riggs's avatar Simon Riggs

Always SnapshotResetXmin() during ClearTransaction()

Avoid corner cases during 2PC with 6bad580d
parent 32173270
...@@ -2640,7 +2640,7 @@ CleanupTransaction(void) ...@@ -2640,7 +2640,7 @@ CleanupTransaction(void)
* do abort cleanup processing * do abort cleanup processing
*/ */
AtCleanup_Portals(); /* now safe to release portal memory */ AtCleanup_Portals(); /* now safe to release portal memory */
AtEOXact_Snapshot(false, false); /* and release the transaction's snapshots */ AtEOXact_Snapshot(false, true); /* and release the transaction's snapshots */
CurrentResourceOwner = NULL; /* and resource owner */ CurrentResourceOwner = NULL; /* and resource owner */
if (TopTransactionResourceOwner) if (TopTransactionResourceOwner)
......
...@@ -1051,7 +1051,7 @@ AtSubAbort_Snapshot(int level) ...@@ -1051,7 +1051,7 @@ AtSubAbort_Snapshot(int level)
* Snapshot manager's cleanup function for end of transaction * Snapshot manager's cleanup function for end of transaction
*/ */
void void
AtEOXact_Snapshot(bool isCommit, bool isPrepare) AtEOXact_Snapshot(bool isCommit, bool resetXmin)
{ {
/* /*
* In transaction-snapshot mode we must release our privately-managed * In transaction-snapshot mode we must release our privately-managed
...@@ -1137,16 +1137,15 @@ AtEOXact_Snapshot(bool isCommit, bool isPrepare) ...@@ -1137,16 +1137,15 @@ AtEOXact_Snapshot(bool isCommit, bool isPrepare)
FirstSnapshotSet = false; FirstSnapshotSet = false;
/* /*
* During normal commit and abort processing, we call * During normal commit processing, we call
* ProcArrayEndTransaction() or ProcArrayClearTransaction() to * ProcArrayEndTransaction() to reset the PgXact->xmin. That call
* reset the PgXact->xmin. That call happens prior to the call to * happens prior to the call to AtEOXact_Snapshot(), so we need
* AtEOXact_Snapshot(), so we need not touch xmin here at all, * not touch xmin here at all.
* accept when we are preparing a transaction.
*/ */
if (isPrepare) if (resetXmin)
SnapshotResetXmin(); SnapshotResetXmin();
Assert(isPrepare || MyPgXact->xmin == 0); Assert(resetXmin || MyPgXact->xmin == 0);
} }
......
...@@ -85,7 +85,7 @@ extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner); ...@@ -85,7 +85,7 @@ extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner);
extern void AtSubCommit_Snapshot(int level); extern void AtSubCommit_Snapshot(int level);
extern void AtSubAbort_Snapshot(int level); extern void AtSubAbort_Snapshot(int level);
extern void AtEOXact_Snapshot(bool isCommit, bool isPrepare); extern void AtEOXact_Snapshot(bool isCommit, bool resetXmin);
extern void ImportSnapshot(const char *idstr); extern void ImportSnapshot(const char *idstr);
extern bool XactHasExportedSnapshots(void); extern bool XactHasExportedSnapshots(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment