]> granicus.if.org Git - postgresql/commitdiff
Always SnapshotResetXmin() during ClearTransaction()
authorSimon Riggs <simon@2ndQuadrant.com>
Thu, 6 Apr 2017 14:30:22 +0000 (10:30 -0400)
committerSimon Riggs <simon@2ndQuadrant.com>
Thu, 6 Apr 2017 14:30:22 +0000 (10:30 -0400)
Avoid corner cases during 2PC with 6bad580d9e678a0b604883e14d8401d469b06566

src/backend/access/transam/xact.c
src/backend/utils/time/snapmgr.c
src/include/utils/snapmgr.h

index 84409ea956284b1c19417571ef9bd32915580671..92b263aea1c401cdc65de5b407d53ec288c98b34 100644 (file)
@@ -2640,7 +2640,7 @@ CleanupTransaction(void)
         * do abort cleanup processing
         */
        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 */
        if (TopTransactionResourceOwner)
index dff3d51ec3c1c40ba7d21c794fa653a7d56214ad..3d92494e0bad453761aafee4a990854506bd5cdb 100644 (file)
@@ -1051,7 +1051,7 @@ AtSubAbort_Snapshot(int level)
  *             Snapshot manager's cleanup function for end of transaction
  */
 void
-AtEOXact_Snapshot(bool isCommit, bool isPrepare)
+AtEOXact_Snapshot(bool isCommit, bool resetXmin)
 {
        /*
         * In transaction-snapshot mode we must release our privately-managed
@@ -1137,16 +1137,15 @@ AtEOXact_Snapshot(bool isCommit, bool isPrepare)
        FirstSnapshotSet = false;
 
        /*
-        * During normal commit and abort processing, we call
-        * ProcArrayEndTransaction() or ProcArrayClearTransaction() to
-        * reset the PgXact->xmin. That call happens prior to the call to
-        * AtEOXact_Snapshot(), so we need not touch xmin here at all,
-        * accept when we are preparing a transaction.
+        * During normal commit processing, we call
+        * ProcArrayEndTransaction() to reset the PgXact->xmin. That call
+        * happens prior to the call to AtEOXact_Snapshot(), so we need
+        * not touch xmin here at all.
         */
-       if (isPrepare)
+       if (resetXmin)
                SnapshotResetXmin();
 
-       Assert(isPrepare || MyPgXact->xmin == 0);
+       Assert(resetXmin || MyPgXact->xmin == 0);
 }
 
 
index 2f8d4fd4a0ca531c85d504888e080cb9b4ec0c4e..2a3f8eca34f82f407ddd05af5e53783c49fd34b2 100644 (file)
@@ -85,7 +85,7 @@ extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner);
 
 extern void AtSubCommit_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 bool XactHasExportedSnapshots(void);