Hello, I looked this from another point of view.
I consider the current discussion to be based on how to predict
the last consistency point. But there is another aspect of this
issue.
I tried to postpone smgrtruncate after the next checkpoint. This
is similar to what hotstandby feedback does to vacuum. It seems
to be working fine but I warry that it might also bloats the
table. I haven't found the way to postpone only objective
smgrtruncate.
The patch below is a immediate verification patch for this
solution.
- CreateCheckPoint records the oldest xmin at that point. Let's
call it 'checkpoint xmin'.
- vacuum skips the modification by the transactions at the same
time or after the checkpoint xmin.
What do you think of this?
--
Kyotaro Horiguchi
NTT Open Source Software Center
=========
diff --git a/src/backend/access/transam/xlog.c
b/src/backend/access/transam/xlog.c
index 479c14d..a274393 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -493,6 +493,7 @@ typedef struct XLogCtlData
XLogRecPtr lastFpwDisableRecPtr;
slock_t info_lck; /* locks shared variables shown
above */
+ TransactionId chkptxactid;
} XLogCtlData;
static XLogCtlData *XLogCtl = NULL;
@@ -676,6 +677,11 @@ static bool read_backup_label(XLogRecPtr *checkPointLoc,
static void rm_redo_error_callback(void *arg);
static int get_sync_bit(int method);
+TransactionId
+XLogGetChkptTrId()
+{
+ return XLogCtl->chkptxactid;
+}
/*
* Insert an XLOG record having the specified RMID and info bytes,
@@ -3875,7 +3881,7 @@ XLOGShmemInit(void)
SpinLockInit(&XLogCtl->info_lck);
SpinLockInit(&XLogCtl->ulsn_lck);
InitSharedLatch(&XLogCtl->recoveryWakeupLatch);
-
+ XLogCtl->chkptxactid = InvalidTransactionId;
/*
* If we are not in bootstrap mode, pg_control should already exist.
Read
* and validate it immediately (see comments in ReadControlFile() for
the
@@ -6700,6 +6706,8 @@ CreateCheckPoint(int flags)
else
checkPoint.oldestActiveXid = InvalidTransactionId;
+ XLogCtl->chkptxactid = GetOldestXmin(true, true);
+
/*
* We must hold WALInsertLock while examining insert state to determine
* the checkpoint REDO pointer.
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 4800b43..79205a0 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -374,6 +374,7 @@ get_rel_oids(Oid relid, const RangeVar *vacrel)
/*
* vacuum_set_xid_limits() -- compute oldest-Xmin and freeze cutoff points
*/
+extern TransactionId XLogGetChkptTrId(void);
void
vacuum_set_xid_limits(int freeze_min_age,
int freeze_table_age,
@@ -397,6 +398,11 @@ vacuum_set_xid_limits(int freeze_min_age,
* always an independent transaction.
*/
*oldestXmin = GetOldestXmin(sharedRel, true);
+ {
+ TransactionId chkpttrid = XLogGetChkptTrId();
+ if (chkpttrid < *oldestXmin)
+ *oldestXmin = chkpttrid;
+ }
Assert(TransactionIdIsNormal(*oldestXmin));
==========
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers