summaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-08-23 23:22:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-08-23 23:22:45 +0000
commit4dbb880d3c77a580ef9634b93af26eaf64484ddb (patch)
tree9caf91a5e2b4746f56eaa769033ecaeef06ca4d6 /src/backend/storage
parent059912ce2e1952a591d2d61d666b07aed5fa8ad6 (diff)
Rearrange pg_subtrans handling as per recent discussion. pg_subtrans
updates are no longer WAL-logged nor even fsync'd; we do not need to, since after a crash no old pg_subtrans data is needed again. We truncate pg_subtrans to RecentGlobalXmin at each checkpoint. slru.c's API is refactored a little bit to separate out the necessary decisions.
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/ipc/sinval.c17
-rw-r--r--src/backend/storage/lmgr/lwlock.c13
2 files changed, 21 insertions, 9 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index f28a883572e..dd9ca8244f3 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.69 2004/08/22 02:41:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.70 2004/08/23 23:22:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -661,6 +661,9 @@ result_known:
* FALSE is sufficient for non-shared relations, since only backends in my
* own database could ever see the tuples in them.
*
+ * This is also used to determine where to truncate pg_subtrans. allDbs
+ * must be TRUE for that case.
+ *
* Note: we include the currently running xids in the set of considered xids.
* This ensures that if a just-started xact has not yet set its snapshot,
* when it does set the snapshot it cannot set xmin less than what we compute.
@@ -673,7 +676,17 @@ GetOldestXmin(bool allDbs)
TransactionId result;
int index;
- result = GetTopTransactionId();
+ /*
+ * Normally we start the min() calculation with our own XID. But
+ * if called by checkpointer, we will not be inside a transaction,
+ * so use next XID as starting point for min() calculation. (Note
+ * that if there are no xacts running at all, that will be the subtrans
+ * truncation point!)
+ */
+ if (IsTransactionState())
+ result = GetTopTransactionId();
+ else
+ result = ReadNewTransactionId();
LWLockAcquire(SInvalLock, LW_SHARED);
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index e48531c10ac..f3ee1173a54 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -15,14 +15,13 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.21 2004/07/01 00:50:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.22 2004/08/23 23:22:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#include "access/clog.h"
-#include "access/subtrans.h"
+#include "access/slru.h"
#include "storage/lwlock.h"
#include "storage/proc.h"
#include "storage/spin.h"
@@ -109,11 +108,11 @@ NumLWLocks(void)
/* bufmgr.c needs two for each shared buffer */
numLocks += 2 * NBuffers;
- /* clog.c needs one per CLOG buffer + one control lock */
- numLocks += NUM_CLOG_BUFFERS + 1;
+ /* clog.c needs one per CLOG buffer */
+ numLocks += NUM_SLRU_BUFFERS;
- /* subtrans.c needs one per SubTrans buffer + one control lock */
- numLocks += NUM_SUBTRANS_BUFFERS + 1;
+ /* subtrans.c needs one per SubTrans buffer */
+ numLocks += NUM_SLRU_BUFFERS;
/* Perhaps create a few more for use by user-defined modules? */