Rename stuff.
authorRobert Haas <rhaas@postgresql.org>
Tue, 28 Jan 2014 15:26:13 +0000 (10:26 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 28 Jan 2014 15:26:13 +0000 (10:26 -0500)
src/backend/access/transam/xlog.c
src/backend/replication/slot.c
src/backend/replication/walsender.c
src/backend/storage/ipc/procarray.c
src/include/access/xlog.h
src/include/replication/slot.h
src/include/storage/procarray.h

index 8d52bdcd9e85438304f7c8f3abb1436ba7a6cb06..c420fc38296e8a1e6af20c2fe524e27be9f4d948 100644 (file)
@@ -486,7 +486,7 @@ typedef struct XLogCtlData
        uint32          ckptXidEpoch;   /* nextXID & epoch of latest checkpoint */
        TransactionId ckptXid;
        XLogRecPtr      asyncXactLSN;   /* LSN of newest async commit/abort */
-       XLogRecPtr      peggedLSN;              /* LSN after which segments can be removed */
+       XLogRecPtr      replicationSlotMinLSN;  /* oldest LSN needed by any slot */
 
        XLogSegNo       lastRemovedSegNo;               /* latest removed/recycled XLOG
                                                                                 * segment */
@@ -751,7 +751,7 @@ static void LocalSetXLogInsertAllowed(void);
 static void CreateEndOfRecoveryRecord(void);
 static void CheckPointGuts(XLogRecPtr checkPointRedo, int flags);
 static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo);
-static XLogRecPtr XLogGetPeggedLSN(void);
+static XLogRecPtr XLogGetReplicationSlotMinimumLSN(void);
 
 static bool XLogCheckBuffer(XLogRecData *rdata, bool holdsExclusiveLock,
                                XLogRecPtr *lsn, BkpBlock *bkpb);
@@ -2913,33 +2913,33 @@ XLogSetAsyncXactLSN(XLogRecPtr asyncXactLSN)
 }
 
 /*
- * Record the LSN up to which we can remove WAL because it's not required for
- * replication.
+ * Record the LSN up to which we can remove WAL because it's not required by
+ * any replication slot.
  */
 void
-XLogSetPeggedLSN(XLogRecPtr lsn)
+XLogSetReplicationSlotMinimumLSN(XLogRecPtr lsn)
 {
        /* use volatile pointer to prevent code rearrangement */
        volatile XLogCtlData *xlogctl = XLogCtl;
 
        SpinLockAcquire(&xlogctl->info_lck);
-       xlogctl->peggedLSN = lsn;
+       xlogctl->replicationSlotMinLSN = lsn;
        SpinLockRelease(&xlogctl->info_lck);
 }
 
 
 /*
- * Return the LSN up to which we can remove WAL because it's not required for
- * replication.
+ * Return the oldest LSN we must retain to satisfy the needs of some
+ * replication slot.
  */
 static XLogRecPtr
-XLogGetPeggedLSN(void)
+XLogGetReplicationSlotMinimumLSN(void)
 {
        /* use volatile pointer to prevent code rearrangement */
        volatile XLogCtlData *xlogctl = XLogCtl;
        XLogRecPtr              retval;
        SpinLockAcquire(&xlogctl->info_lck);
-       retval = xlogctl->peggedLSN;
+       retval = xlogctl->replicationSlotMinLSN;
        SpinLockRelease(&xlogctl->info_lck);
 
        return retval;
@@ -8988,7 +8988,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
        XLogRecPtr      keep;
 
        XLByteToSeg(recptr, segno);
-       keep = XLogGetPeggedLSN();
+       keep = XLogGetReplicationSlotMinimumLSN();
 
        /* compute limit for wal_keep_segments first */
        if (wal_keep_segments > 0)
index a0a96171853d95eca1873ec8b3cbaf3bab57f738..d80eddfdac77debbc755ec627bae58fc725970d3 100644 (file)
@@ -470,7 +470,7 @@ ReplicationSlotDrop(const char *name)
        LWLockRelease(ReplicationSlotControlLock);
 
        /* slot is dead and doesn't nail the xmin anymore, recompute horizon */
-       ReplicationSlotsComputeRequiredXmin(false);
+       ReplicationSlotsComputeRequiredXmin();
 
        /*
         * If removing the directory fails, the worst thing that will happen is
@@ -511,7 +511,7 @@ ReplicationSlotSave()
  * If already_locked is passed in ProcArrayLock is already held exlusively.
  */
 void
-ReplicationSlotsComputeRequiredXmin(bool already_locked)
+ReplicationSlotsComputeRequiredXmin(void)
 {
        int                     i;
        TransactionId agg_data_xmin = InvalidTransactionId;
@@ -543,7 +543,7 @@ ReplicationSlotsComputeRequiredXmin(bool already_locked)
        }
        LWLockRelease(ReplicationSlotControlLock);
 
-       ProcArraySetPeggedXmin(agg_data_xmin, already_locked);
+       ProcArraySetReplicationSlotXmin(agg_data_xmin);
 }
 
 /*
@@ -582,7 +582,7 @@ ReplicationSlotsComputeRequiredLSN(void)
        }
        LWLockRelease(ReplicationSlotControlLock);
 
-       XLogSetPeggedLSN(min_required);
+       XLogSetReplicationSlotMinimumLSN(min_required);
 }
 
 /*
@@ -698,7 +698,7 @@ StartupReplicationSlots(XLogRecPtr checkPointRedo)
                return;
 
        /* Now that we have recovered all the data, compute replication xmin */
-       ReplicationSlotsComputeRequiredXmin(false);
+       ReplicationSlotsComputeRequiredXmin();
        ReplicationSlotsComputeRequiredLSN();
 }
 
index 76acdfa0a292e9db6aa0167fa451871efff8c042..7c9dbd4374634a12b50c6089195e6519f5f8b602 100644 (file)
@@ -1094,7 +1094,7 @@ PhysicalReplicationSlotNewXmin(TransactionId feedbackXmin)
        if (changed)
        {
                ReplicationSlotSave();
-               ReplicationSlotsComputeRequiredXmin(false);
+               ReplicationSlotsComputeRequiredXmin();
        }
 }
 
index a6ced4dd05165c4b2e407ec2077db4e02cf8ebad..082115b4fffdf2edb363d7eee20daa030780b02a 100644 (file)
@@ -82,8 +82,8 @@ typedef struct ProcArrayStruct
         */
        TransactionId lastOverflowedXid;
 
-       /* globally "pegged" xmin horizons */
-       TransactionId pegged_xmin;
+       /* oldest xmin of any replication slot */
+       TransactionId replication_slot_xmin;
 
        /*
         * We declare pgprocnos[] as 1 entry because C wants a fixed-size array,
@@ -231,7 +231,7 @@ CreateSharedProcArray(void)
                 */
                procArray->numProcs = 0;
                procArray->maxProcs = PROCARRAY_MAXPROCS;
-               procArray->pegged_xmin = InvalidTransactionId;
+               procArray->replication_slot_xmin = InvalidTransactionId;
                procArray->maxKnownAssignedXids = TOTAL_MAX_CACHED_SUBXIDS;
                procArray->numKnownAssignedXids = 0;
                procArray->tailKnownAssignedXids = 0;
@@ -1157,7 +1157,7 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
        ProcArrayStruct *arrayP = procArray;
        TransactionId result;
        int                     index;
-       volatile TransactionId pegged_xmin = InvalidTransactionId;
+       volatile TransactionId replication_slot_xmin = InvalidTransactionId;
 
        /* Cannot look for individual databases during recovery */
        Assert(allDbs || !RecoveryInProgress());
@@ -1210,7 +1210,7 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
        }
 
        /* fetch into volatile var while ProcArrayLock is held */
-       pegged_xmin = procArray->pegged_xmin;
+       replication_slot_xmin = procArray->replication_slot_xmin;
 
        if (RecoveryInProgress())
        {
@@ -1253,11 +1253,11 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
        }
 
        /*
-        * Check whether there's physical slots requiring xmin to be pegged.
+        * Check whether there are replication slots requiring an older xmin.
         */
-       if (TransactionIdIsValid(pegged_xmin) &&
-               NormalTransactionIdPrecedes(pegged_xmin, result))
-               result = pegged_xmin;
+       if (TransactionIdIsValid(replication_slot_xmin) &&
+               NormalTransactionIdPrecedes(replication_slot_xmin, result))
+               result = replication_slot_xmin;
 
        return result;
 }
@@ -1328,7 +1328,7 @@ GetSnapshotData(Snapshot snapshot)
        int                     count = 0;
        int                     subcount = 0;
        bool            suboverflowed = false;
-       volatile TransactionId pegged_xmin = InvalidTransactionId;
+       volatile TransactionId replication_slot_xmin = InvalidTransactionId;
 
        Assert(snapshot != NULL);
 
@@ -1508,7 +1508,7 @@ GetSnapshotData(Snapshot snapshot)
 
 
        /* fetch into volatile var while ProcArrayLock is held */
-       pegged_xmin = procArray->pegged_xmin;
+       replication_slot_xmin = procArray->replication_slot_xmin;
 
        if (!TransactionIdIsValid(MyPgXact->xmin))
                MyPgXact->xmin = TransactionXmin = xmin;
@@ -1528,13 +1528,10 @@ GetSnapshotData(Snapshot snapshot)
        if (!TransactionIdIsNormal(RecentGlobalXmin))
                RecentGlobalXmin = FirstNormalTransactionId;
 
-       /*
-        * Check whether there's a physical slot requiring the global xmin to be
-        * pegged for all tables.
-        */
-       if (TransactionIdIsValid(pegged_xmin) &&
-               NormalTransactionIdPrecedes(pegged_xmin, RecentGlobalXmin))
-               RecentGlobalXmin = pegged_xmin;
+       /* Check whether there's a replication slot requiring an older xmin. */
+       if (TransactionIdIsValid(replication_slot_xmin) &&
+               NormalTransactionIdPrecedes(replication_slot_xmin, RecentGlobalXmin))
+               RecentGlobalXmin = replication_slot_xmin;
 
        RecentXmin = xmin;
 
@@ -2522,21 +2519,18 @@ CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared)
 }
 
 /*
- * ProcArraySetPeggedXmin
+ * ProcArraySetReplicationSlotXmin
  *
  * Install limits to future computations of the xmin horizon to prevent vacuum
- * and HOT pruning from removing affected rows.
+ * and HOT pruning from removing affected rows still needed by clients with
+ * replicaton slots.
  */
 void
-ProcArraySetPeggedXmin(TransactionId xmin, bool already_locked)
+ProcArraySetReplicationSlotXmin(TransactionId xmin)
 {
-       if (!already_locked)
-               LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
-
-       procArray->pegged_xmin = xmin;
-
-       if (!already_locked)
-               LWLockRelease(ProcArrayLock);
+       LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
+       procArray->replication_slot_xmin = xmin;
+       LWLockRelease(ProcArrayLock);
 }
 
 
index aab3d40512d69e2067cf0813b9cc06d9306ae478..11ab27719907f2a190aeb70f95de80811b306d9c 100644 (file)
@@ -289,7 +289,7 @@ extern XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std);
 
 extern void CheckXLogRemoved(XLogSegNo segno, TimeLineID tli);
 extern void XLogSetAsyncXactLSN(XLogRecPtr record);
-extern void XLogSetPeggedLSN(XLogRecPtr lsn);
+extern void XLogSetReplicationSlotMinimumLSN(XLogRecPtr lsn);
 
 extern Buffer RestoreBackupBlock(XLogRecPtr lsn, XLogRecord *record,
                                   int block_index,
index 2cd37c0af71453b73ff2fd1992bafb9cb66a2d7a..1b4ccf6e8cca94ecab5da3cef0a1f5c2a54e918b 100644 (file)
@@ -95,7 +95,7 @@ extern void ReplicationSlotSave(void);
 
 /* misc stuff */
 extern bool ReplicationSlotValidateName(const char *name, int elevel);
-extern void ReplicationSlotsComputeRequiredXmin(bool already_locked);
+extern void ReplicationSlotsComputeRequiredXmin(void);
 extern void ReplicationSlotsComputeRequiredLSN(void);
 extern void StartupReplicationSlots(XLogRecPtr checkPointRedo);
 extern void CheckSlotRequirements(void);
index f6c6685072dde8ad194c6e2316fcd13a585501ce..d1a58a3661b0ad6f7389722b7651cdb65b890a8b 100644 (file)
@@ -77,6 +77,6 @@ extern void XidCacheRemoveRunningXids(TransactionId xid,
                                                  int nxids, const TransactionId *xids,
                                                  TransactionId latestXid);
 
-extern void ProcArraySetPeggedXmin(TransactionId xmin, bool already_locked);
+extern void ProcArraySetReplicationSlotXmin(TransactionId xmin);
 
 #endif   /* PROCARRAY_H */