aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2017-04-06 10:30:22 -0400
committerSimon Riggs <simon@2ndQuadrant.com>2017-04-06 10:30:22 -0400
commitcd0cebaf7d1ab04427d4045edf7121a8f3753d8b (patch)
treec3efa68eb8dc9039aa87c56be5eaac8374f09521 /src
parent3217327053638085d24dd4d276e7c1f7ac2c4c6b (diff)
downloadpostgresql-cd0cebaf7d1ab04427d4045edf7121a8f3753d8b.tar.gz
postgresql-cd0cebaf7d1ab04427d4045edf7121a8f3753d8b.zip
Always SnapshotResetXmin() during ClearTransaction()
Avoid corner cases during 2PC with 6bad580d9e678a0b604883e14d8401d469b06566
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xact.c2
-rw-r--r--src/backend/utils/time/snapmgr.c15
-rw-r--r--src/include/utils/snapmgr.h2
3 files changed, 9 insertions, 10 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 84409ea9562..92b263aea1c 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -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)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index dff3d51ec3c..3d92494e0ba 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -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);
}
diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
index 2f8d4fd4a0c..2a3f8eca34f 100644
--- a/src/include/utils/snapmgr.h
+++ b/src/include/utils/snapmgr.h
@@ -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);