summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2011-10-15 11:10:13 +0000
committerRobert Haas2011-10-15 11:10:13 +0000
commita4798f146f4b06ee92f4b857b19c03cb4e188282 (patch)
tree11fcec9bd6a3989b3026f3d79d5292ec3c1413fe
parent68693317d2896934628667f97c3dfec9b2c11ea3 (diff)
Clean up ProcArrayEndTransaction().
-rw-r--r--src/backend/access/transam/xact.c4
-rw-r--r--src/backend/storage/ipc/procarray.c57
-rw-r--r--src/include/storage/procarray.h2
3 files changed, 14 insertions, 49 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 9c1e072d15..fb40b801e2 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1853,9 +1853,9 @@ CommitTransaction(void)
* must be done _before_ releasing locks we hold and _after_
* RecordTransactionCommit.
*/
- ProcArrayEndTransaction(MyProc, latestXid);
if (TransactionIdIsNormal(xid))
SnapArrayRemoveRunningXids(xid, nchildren, children, latestXid);
+ ProcArrayEndTransaction(MyProc);
/*
* This is all post-commit cleanup. Note that if an error is raised here,
@@ -2285,9 +2285,9 @@ AbortTransaction(void)
* must be done _before_ releasing locks we hold and _after_
* RecordTransactionAbort.
*/
- ProcArrayEndTransaction(MyProc, latestXid);
if (TransactionIdIsNormal(xid))
SnapArrayRemoveRunningXids(xid, nchildren, children, latestXid);
+ ProcArrayEndTransaction(MyProc);
/*
* Post-abort cleanup. See notes in CommitTransaction() concerning
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 5145e5b054..232c741ca7 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -279,58 +279,23 @@ ProcArrayRemove(PGPROC *proc)
* commit/abort must already be reported to WAL and pg_clog.
*
* proc is currently always MyProc, but we pass it explicitly for flexibility.
- * latestXid is the latest Xid among the transaction's main XID and
- * subtransactions, or InvalidTransactionId if it has no XID. (We must ask
- * the caller to pass latestXid, instead of computing it from the PGPROC's
- * contents, because the subxid information in the PGPROC might be
- * incomplete.)
*/
void
-ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
+ProcArrayEndTransaction(PGPROC *proc)
{
- /*
- * XXX. This code can be further simplified now that we no longer
- * use the PGPROC->xid fields to derive a snapshot.
- */
-
- if (TransactionIdIsValid(latestXid))
- {
- Assert(TransactionIdIsValid(proc->xid));
-
- proc->xid = InvalidTransactionId;
- proc->lxid = InvalidLocalTransactionId;
- proc->xmin = InvalidTransactionId;
- /* must be cleared with xid/xmin: */
- proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;
- proc->inCommit = false; /* be sure this is cleared in abort */
- proc->recoveryConflictPending = false;
-
- /* Clear the subtransaction-XID cache too while holding the lock */
- proc->subxids.nxids = 0;
- proc->subxids.overflowed = false;
- }
- else
- {
- /*
- * If we have no XID, we don't need to lock, since we won't affect
- * anyone else's calculation of a snapshot. We might change their
- * estimate of global xmin, but that's OK.
- */
- Assert(!TransactionIdIsValid(proc->xid));
-
- proc->lxid = InvalidLocalTransactionId;
- proc->xmin = InvalidTransactionId;
- /* must be cleared with xid/xmin: */
- proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;
- proc->inCommit = false; /* be sure this is cleared in abort */
- proc->recoveryConflictPending = false;
+ proc->xid = InvalidTransactionId;
+ proc->lxid = InvalidLocalTransactionId;
+ proc->xmin = InvalidTransactionId;
+ /* must be cleared with xid/xmin: */
+ proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;
+ proc->inCommit = false; /* be sure this is cleared in abort */
+ proc->recoveryConflictPending = false;
- Assert(proc->subxids.nxids == 0);
- Assert(proc->subxids.overflowed == false);
- }
+ /* Clear the subtransaction-XID cache too while holding the lock */
+ proc->subxids.nxids = 0;
+ proc->subxids.overflowed = false;
}
-
/*
* ProcArrayClearTransaction -- clear the transaction fields
*
diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h
index 072bd2b5a7..eb5238f01f 100644
--- a/src/include/storage/procarray.h
+++ b/src/include/storage/procarray.h
@@ -23,7 +23,7 @@ extern void CreateSharedProcArray(void);
extern void ProcArrayAdd(PGPROC *proc);
extern void ProcArrayRemove(PGPROC *proc);
-extern void ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid);
+extern void ProcArrayEndTransaction(PGPROC *proc);
extern void ProcArrayClearTransaction(PGPROC *proc);
extern void ProcArrayApplyRecoveryInfo(RunningTransactions running);