Standardize rmgrdesc recovery conflict XID output.
authorPeter Geoghegan
Thu, 17 Nov 2022 22:55:08 +0000 (14:55 -0800)
committerPeter Geoghegan
Thu, 17 Nov 2022 22:55:08 +0000 (14:55 -0800)
Standardize on the name snapshotConflictHorizon for all XID fields from
WAL records that generate recovery conflicts when in hot standby mode.
This supersedes the previous latestRemovedXid naming convention.

The new naming convention places emphasis on how the values are actually
used by REDO routines.  How the values are generated during original
execution (details of which vary by record type) is deemphasized.  Users
of tools like pg_waldump can now grep for snapshotConflictHorizon to see
all potential sources of recovery conflicts in a standardized way,
without necessarily having to consider which specific record types might
be involved.

Also bring a couple of WAL record types that didn't follow any kind of
naming convention into line.  These are heapam's VISIBLE record type and
SP-GiST's VACUUM_REDIRECT record type.  Now every WAL record whose REDO
routine calls ResolveRecoveryConflictWithSnapshot() passes through the
snapshotConflictHorizon field from its WAL record.  This is follow-up
work to the refactoring from commit 9e540599 that made FREEZE_PAGE WAL
records use a standard snapshotConflictHorizon style XID cutoff.

No bump in XLOG_PAGE_MAGIC, since the underlying format of affected WAL
records doesn't change.

Author: Peter Geoghegan 
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/CAH2-Wzm2CQUmViUq7Opgk=McVREHSOorYaAjR1ZpLYkRN7_dPw@mail.gmail.com

27 files changed:
src/backend/access/gist/gist.c
src/backend/access/gist/gistxlog.c
src/backend/access/hash/hash_xlog.c
src/backend/access/hash/hashinsert.c
src/backend/access/heap/heapam.c
src/backend/access/heap/pruneheap.c
src/backend/access/index/genam.c
src/backend/access/nbtree/README
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtxlog.c
src/backend/access/rmgrdesc/gistdesc.c
src/backend/access/rmgrdesc/hashdesc.c
src/backend/access/rmgrdesc/heapdesc.c
src/backend/access/rmgrdesc/nbtdesc.c
src/backend/access/rmgrdesc/spgdesc.c
src/backend/access/spgist/spgvacuum.c
src/backend/access/spgist/spgxlog.c
src/backend/storage/ipc/procarray.c
src/backend/storage/ipc/standby.c
src/include/access/gist_private.h
src/include/access/gistxlog.h
src/include/access/hash_xlog.h
src/include/access/heapam_xlog.h
src/include/access/nbtxlog.h
src/include/access/spgxlog.h
src/include/access/tableam.h
src/include/storage/standby.h

index 30069f139c7555b81282713fc9528141ab37af8c..3e275e67008bdfd63ee1688d2d103d78d51acdf0 100644 (file)
@@ -1665,10 +1665,10 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
 
    if (ndeletable > 0)
    {
-       TransactionId latestRemovedXid = InvalidTransactionId;
+       TransactionId snapshotConflictHorizon = InvalidTransactionId;
 
        if (XLogStandbyInfoActive() && RelationNeedsWAL(rel))
-           latestRemovedXid =
+           snapshotConflictHorizon =
                index_compute_xid_horizon_for_tuples(rel, heapRel, buffer,
                                                     deletable, ndeletable);
 
@@ -1694,7 +1694,7 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
 
            recptr = gistXLogDelete(buffer,
                                    deletable, ndeletable,
-                                   latestRemovedXid);
+                                   snapshotConflictHorizon);
 
            PageSetLSN(page, recptr);
        }
index 998befd2cbb7eb99fd79fd519e0ece0e87b49a48..cb5affa3d2723f1f2c4a746d7f8dd757d21398b9 100644 (file)
@@ -195,7 +195,7 @@ gistRedoDeleteRecord(XLogReaderState *record)
 
        XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
 
-       ResolveRecoveryConflictWithSnapshot(xldata->latestRemovedXid,
+       ResolveRecoveryConflictWithSnapshot(xldata->snapshotConflictHorizon,
                                            rlocator);
    }
 
@@ -388,14 +388,14 @@ gistRedoPageReuse(XLogReaderState *record)
     * PAGE_REUSE records exist to provide a conflict point when we reuse
     * pages in the index via the FSM.  That's all they do though.
     *
-    * latestRemovedXid was the page's deleteXid.  The
+    * snapshotConflictHorizon was the page's deleteXid.  The
     * GlobalVisCheckRemovableFullXid(deleteXid) test in gistPageRecyclable()
     * conceptually mirrors the PGPROC->xmin > limitXmin test in
     * GetConflictingVirtualXIDs().  Consequently, one XID value achieves the
     * same exclusion effect on primary and standby.
     */
    if (InHotStandby)
-       ResolveRecoveryConflictWithSnapshotFullXid(xlrec->latestRemovedFullXid,
+       ResolveRecoveryConflictWithSnapshotFullXid(xlrec->snapshotConflictHorizon,
                                                   xlrec->locator);
 }
 
@@ -597,7 +597,7 @@ gistXLogAssignLSN(void)
  * Write XLOG record about reuse of a deleted page.
  */
 void
-gistXLogPageReuse(Relation rel, BlockNumber blkno, FullTransactionId latestRemovedXid)
+gistXLogPageReuse(Relation rel, BlockNumber blkno, FullTransactionId deleteXid)
 {
    gistxlogPageReuse xlrec_reuse;
 
@@ -610,7 +610,7 @@ gistXLogPageReuse(Relation rel, BlockNumber blkno, FullTransactionId latestRemov
    /* XLOG stuff */
    xlrec_reuse.locator = rel->rd_locator;
    xlrec_reuse.block = blkno;
-   xlrec_reuse.latestRemovedFullXid = latestRemovedXid;
+   xlrec_reuse.snapshotConflictHorizon = deleteXid;
 
    XLogBeginInsert();
    XLogRegisterData((char *) &xlrec_reuse, SizeOfGistxlogPageReuse);
@@ -672,12 +672,12 @@ gistXLogUpdate(Buffer buffer,
  */
 XLogRecPtr
 gistXLogDelete(Buffer buffer, OffsetNumber *todelete, int ntodelete,
-              TransactionId latestRemovedXid)
+              TransactionId snapshotConflictHorizon)
 {
    gistxlogDelete xlrec;
    XLogRecPtr  recptr;
 
-   xlrec.latestRemovedXid = latestRemovedXid;
+   xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
    xlrec.ntodelete = ntodelete;
 
    XLogBeginInsert();
@@ -685,7 +685,8 @@ gistXLogDelete(Buffer buffer, OffsetNumber *todelete, int ntodelete,
 
    /*
     * We need the target-offsets array whether or not we store the whole
-    * buffer, to allow us to find the latestRemovedXid on a standby server.
+    * buffer, to allow us to find the snapshotConflictHorizon on a standby
+    * server.
     */
    XLogRegisterData((char *) todelete, ntodelete * sizeof(OffsetNumber));
 
index a24a1c39081785113e0308f937907bdd42a0abb8..b452697a2f82a07209d4b20d6e321bbfccd24301 100644 (file)
@@ -1000,7 +1000,8 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
        RelFileLocator rlocator;
 
        XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
-       ResolveRecoveryConflictWithSnapshot(xldata->latestRemovedXid, rlocator);
+       ResolveRecoveryConflictWithSnapshot(xldata->snapshotConflictHorizon,
+                                           rlocator);
    }
 
    action = XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &buffer);
index 4f2fecb908eebc45afe4cccd621265944dff9eff..23907d2e5b11f64d6f363bba239a0089c54ac3e2 100644 (file)
@@ -360,9 +360,9 @@ _hash_vacuum_one_page(Relation rel, Relation hrel, Buffer metabuf, Buffer buf)
 
    if (ndeletable > 0)
    {
-       TransactionId latestRemovedXid;
+       TransactionId snapshotConflictHorizon;
 
-       latestRemovedXid =
+       snapshotConflictHorizon =
            index_compute_xid_horizon_for_tuples(rel, hrel, buf,
                                                 deletable, ndeletable);
 
@@ -399,7 +399,7 @@ _hash_vacuum_one_page(Relation rel, Relation hrel, Buffer metabuf, Buffer buf)
            xl_hash_vacuum_one_page xlrec;
            XLogRecPtr  recptr;
 
-           xlrec.latestRemovedXid = latestRemovedXid;
+           xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
            xlrec.ntuples = ndeletable;
 
            XLogBeginInsert();
@@ -408,8 +408,8 @@ _hash_vacuum_one_page(Relation rel, Relation hrel, Buffer metabuf, Buffer buf)
 
            /*
             * We need the target-offsets array whether or not we store the
-            * whole buffer, to allow us to find the latestRemovedXid on a
-            * standby server.
+            * whole buffer, to allow us to find the snapshotConflictHorizon
+            * on a standby server.
             */
            XLogRegisterData((char *) deletable,
                             ndeletable * sizeof(OffsetNumber));
index 9790ba2298226a367630de4a7a27c141de7b14f2..d18c5ca6f586b0fc0431efb13e3669fd601a2fdb 100644 (file)
@@ -6792,7 +6792,7 @@ heap_freeze_execute_prepared(Relation rel, Buffer buffer,
    Page        page = BufferGetPage(buffer);
 
    Assert(ntuples > 0);
-   Assert(TransactionIdIsValid(FreezeLimit));
+   Assert(TransactionIdIsNormal(FreezeLimit));
 
    START_CRIT_SECTION();
 
@@ -6815,21 +6815,20 @@ heap_freeze_execute_prepared(Relation rel, Buffer buffer,
        int         nplans;
        xl_heap_freeze_page xlrec;
        XLogRecPtr  recptr;
-       TransactionId latestRemovedXid;
+       TransactionId snapshotConflictHorizon;
 
        /* Prepare deduplicated representation for use in WAL record */
        nplans = heap_xlog_freeze_plan(tuples, ntuples, plans, offsets);
 
        /*
-        * latestRemovedXid describes the latest processed XID, whereas
         * FreezeLimit is (approximately) the first XID not frozen by VACUUM.
         * Back up caller's FreezeLimit to avoid false conflicts when
         * FreezeLimit is precisely equal to VACUUM's OldestXmin cutoff.
         */
-       latestRemovedXid = FreezeLimit;
-       TransactionIdRetreat(latestRemovedXid);
+       snapshotConflictHorizon = FreezeLimit;
+       TransactionIdRetreat(snapshotConflictHorizon);
 
-       xlrec.latestRemovedXid = latestRemovedXid;
+       xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
        xlrec.nplans = nplans;
 
        XLogBeginInsert();
@@ -7401,15 +7400,21 @@ heap_tuple_would_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
 }
 
 /*
- * If 'tuple' contains any visible XID greater than latestRemovedXid,
- * ratchet forwards latestRemovedXid to the greatest one found.
- * This is used as the basis for generating Hot Standby conflicts, so
- * if a tuple was never visible then removing it should not conflict
- * with queries.
+ * Maintain snapshotConflictHorizon for caller by ratcheting forward its value
+ * using any committed XIDs contained in 'tuple', an obsolescent heap tuple
+ * that caller is in the process of physically removing, e.g. via HOT pruning
+ * or index deletion.
+ *
+ * Caller must initialize its value to InvalidTransactionId, which is
+ * generally interpreted as "definitely no need for a recovery conflict".
+ * Final value must reflect all heap tuples that caller will physically remove
+ * (or remove TID references to) via its ongoing pruning/deletion operation.
+ * ResolveRecoveryConflictWithSnapshot() is passed the final value (taken from
+ * caller's WAL record) by REDO routine when it replays caller's operation.
  */
 void
-HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
-                                      TransactionId *latestRemovedXid)
+HeapTupleHeaderAdvanceConflictHorizon(HeapTupleHeader tuple,
+                                     TransactionId *snapshotConflictHorizon)
 {
    TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
    TransactionId xmax = HeapTupleHeaderGetUpdateXid(tuple);
@@ -7417,8 +7422,8 @@ HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
 
    if (tuple->t_infomask & HEAP_MOVED)
    {
-       if (TransactionIdPrecedes(*latestRemovedXid, xvac))
-           *latestRemovedXid = xvac;
+       if (TransactionIdPrecedes(*snapshotConflictHorizon, xvac))
+           *snapshotConflictHorizon = xvac;
    }
 
    /*
@@ -7431,11 +7436,9 @@ HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
        (!HeapTupleHeaderXminInvalid(tuple) && TransactionIdDidCommit(xmin)))
    {
        if (xmax != xmin &&
-           TransactionIdFollows(xmax, *latestRemovedXid))
-           *latestRemovedXid = xmax;
+           TransactionIdFollows(xmax, *snapshotConflictHorizon))
+           *snapshotConflictHorizon = xmax;
    }
-
-   /* *latestRemovedXid may still be invalid at end */
 }
 
 #ifdef USE_PREFETCH
@@ -7558,7 +7561,7 @@ TransactionId
 heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
 {
    /* Initial assumption is that earlier pruning took care of conflict */
-   TransactionId latestRemovedXid = InvalidTransactionId;
+   TransactionId snapshotConflictHorizon = InvalidTransactionId;
    BlockNumber blkno = InvalidBlockNumber;
    Buffer      buf = InvalidBuffer;
    Page        page = NULL;
@@ -7769,8 +7772,8 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
        }
 
        /*
-        * Maintain latestRemovedXid value for deletion operation as a whole
-        * by advancing current value using heap tuple headers.  This is
+        * Maintain snapshotConflictHorizon value for deletion operation as a
+        * whole by advancing current value using heap tuple headers.  This is
         * loosely based on the logic for pruning a HOT chain.
         */
        offnum = ItemPointerGetOffsetNumber(htid);
@@ -7805,12 +7808,12 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
             * LP_DEAD item.  This is okay because the earlier pruning
             * operation that made the line pointer LP_DEAD in the first place
             * must have considered the original tuple header as part of
-            * generating its own latestRemovedXid value.
+            * generating its own snapshotConflictHorizon value.
             *
             * Relying on XLOG_HEAP2_PRUNE records like this is the same
             * strategy that index vacuuming uses in all cases.  Index VACUUM
-            * WAL records don't even have a latestRemovedXid field of their
-            * own for this reason.
+            * WAL records don't even have a snapshotConflictHorizon field of
+            * their own for this reason.
             */
            if (!ItemIdIsNormal(lp))
                break;
@@ -7824,7 +7827,8 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
                !TransactionIdEquals(HeapTupleHeaderGetXmin(htup), priorXmax))
                break;
 
-           HeapTupleHeaderAdvanceLatestRemovedXid(htup, &latestRemovedXid);
+           HeapTupleHeaderAdvanceConflictHorizon(htup,
+                                                 &snapshotConflictHorizon);
 
            /*
             * If the tuple is not HOT-updated, then we are at the end of this
@@ -7856,7 +7860,7 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
    Assert(finalndeltids > 0 || delstate->bottomup);
    delstate->ndeltids = finalndeltids;
 
-   return latestRemovedXid;
+   return snapshotConflictHorizon;
 }
 
 /*
@@ -8232,6 +8236,9 @@ bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate)
  * corresponding visibility map block.  Both should have already been modified
  * and dirtied.
  *
+ * snapshotConflictHorizon comes from the largest xmin on the page being
+ * marked all-visible.  REDO routine uses it to generate recovery conflicts.
+ *
  * If checksums or wal_log_hints are enabled, we may also generate a full-page
  * image of heap_buffer. Otherwise, we optimize away the FPI (by specifying
  * REGBUF_NO_IMAGE for the heap buffer), in which case the caller should *not*
@@ -8239,7 +8246,7 @@ bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate)
  */
 XLogRecPtr
 log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer, Buffer vm_buffer,
-                TransactionId cutoff_xid, uint8 vmflags)
+                TransactionId snapshotConflictHorizon, uint8 vmflags)
 {
    xl_heap_visible xlrec;
    XLogRecPtr  recptr;
@@ -8248,7 +8255,7 @@ log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer, Buffer vm_buffer,
    Assert(BufferIsValid(heap_buffer));
    Assert(BufferIsValid(vm_buffer));
 
-   xlrec.cutoff_xid = cutoff_xid;
+   xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
    xlrec.flags = vmflags;
    XLogBeginInsert();
    XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
@@ -8683,7 +8690,8 @@ heap_xlog_prune(XLogReaderState *record)
     * no queries running for which the removed tuples are still visible.
     */
    if (InHotStandby)
-       ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rlocator);
+       ResolveRecoveryConflictWithSnapshot(xlrec->snapshotConflictHorizon,
+                                           rlocator);
 
    /*
     * If we have a full-page image, restore it (using a cleanup lock) and
@@ -8851,7 +8859,8 @@ heap_xlog_visible(XLogReaderState *record)
     * rather than killing the transaction outright.
     */
    if (InHotStandby)
-       ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, rlocator);
+       ResolveRecoveryConflictWithSnapshot(xlrec->snapshotConflictHorizon,
+                                           rlocator);
 
    /*
     * Read the heap page, if it still exists. If the heap file has dropped or
@@ -8939,7 +8948,7 @@ heap_xlog_visible(XLogReaderState *record)
        visibilitymap_pin(reln, blkno, &vmbuffer);
 
        visibilitymap_set(reln, blkno, InvalidBuffer, lsn, vmbuffer,
-                         xlrec->cutoff_xid, xlrec->flags);
+                         xlrec->snapshotConflictHorizon, xlrec->flags);
 
        ReleaseBuffer(vmbuffer);
        FreeFakeRelcacheEntry(reln);
@@ -9105,7 +9114,8 @@ heap_xlog_freeze_page(XLogReaderState *record)
        RelFileLocator rlocator;
 
        XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
-       ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rlocator);
+       ResolveRecoveryConflictWithSnapshot(xlrec->snapshotConflictHorizon,
+                                           rlocator);
    }
 
    if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
index 9f43bbe25f5bd3c894c71e810a3477e8be5b9600..91c5f5e9efe8fa45ef84c69c0c33d3214391beba 100644 (file)
@@ -49,7 +49,7 @@ typedef struct
    bool        old_snap_used;
 
    TransactionId new_prune_xid;    /* new prune hint value for page */
-   TransactionId latestRemovedXid; /* latest xid to be removed by this prune */
+   TransactionId snapshotConflictHorizon;  /* latest xid removed */
    int         nredirected;    /* numbers of entries in arrays below */
    int         ndead;
    int         nunused;
@@ -295,7 +295,7 @@ heap_page_prune(Relation relation, Buffer buffer,
    prstate.old_snap_xmin = old_snap_xmin;
    prstate.old_snap_ts = old_snap_ts;
    prstate.old_snap_used = false;
-   prstate.latestRemovedXid = InvalidTransactionId;
+   prstate.snapshotConflictHorizon = InvalidTransactionId;
    prstate.nredirected = prstate.ndead = prstate.nunused = 0;
    memset(prstate.marked, 0, sizeof(prstate.marked));
 
@@ -418,7 +418,7 @@ heap_page_prune(Relation relation, Buffer buffer,
            xl_heap_prune xlrec;
            XLogRecPtr  recptr;
 
-           xlrec.latestRemovedXid = prstate.latestRemovedXid;
+           xlrec.snapshotConflictHorizon = prstate.snapshotConflictHorizon;
            xlrec.nredirected = prstate.nredirected;
            xlrec.ndead = prstate.ndead;
 
@@ -636,8 +636,8 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
                !HeapTupleHeaderIsHotUpdated(htup))
            {
                heap_prune_record_unused(prstate, rootoffnum);
-               HeapTupleHeaderAdvanceLatestRemovedXid(htup,
-                                                      &prstate->latestRemovedXid);
+               HeapTupleHeaderAdvanceConflictHorizon(htup,
+                                                     &prstate->snapshotConflictHorizon);
                ndeleted++;
            }
 
@@ -773,8 +773,8 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
        if (tupdead)
        {
            latestdead = offnum;
-           HeapTupleHeaderAdvanceLatestRemovedXid(htup,
-                                                  &prstate->latestRemovedXid);
+           HeapTupleHeaderAdvanceConflictHorizon(htup,
+                                                 &prstate->snapshotConflictHorizon);
        }
        else if (!recent_dead)
            break;
index 98af5347b9fe84659db407427f4c5a052d678e26..01d08960b484243cc6b501b89e3e23acc73560d9 100644 (file)
@@ -275,14 +275,15 @@ BuildIndexValueDescription(Relation indexRelation,
 }
 
 /*
- * Get the latestRemovedXid from the table entries pointed at by the index
- * tuples being deleted using an AM-generic approach.
+ * Get the snapshotConflictHorizon from the table entries pointed to by the
+ * index tuples being deleted using an AM-generic approach.
  *
- * This is a table_index_delete_tuples() shim used by index AMs that have
- * simple requirements.  These callers only need to consult the tableam to get
- * a latestRemovedXid value, and only expect to delete tuples that are already
- * known deletable.  When a latestRemovedXid value isn't needed in index AM's
- * deletion WAL record, it is safe for it to skip calling here entirely.
+ * This is a table_index_delete_tuples() shim used by index AMs that only need
+ * to consult the tableam to get a snapshotConflictHorizon value, and only
+ * expect to delete index tuples that are already known deletable (typically
+ * due to having LP_DEAD bits set).  When a snapshotConflictHorizon value
+ * isn't needed in index AM's deletion WAL record, it is safe for it to skip
+ * calling here entirely.
  *
  * We assume that caller index AM uses the standard IndexTuple representation,
  * with table TIDs stored in the t_tid field.  We also expect (and assert)
@@ -297,7 +298,7 @@ index_compute_xid_horizon_for_tuples(Relation irel,
                                     int nitems)
 {
    TM_IndexDeleteOp delstate;
-   TransactionId latestRemovedXid = InvalidTransactionId;
+   TransactionId snapshotConflictHorizon = InvalidTransactionId;
    Page        ipage = BufferGetPage(ibuf);
    IndexTuple  itup;
 
@@ -333,7 +334,7 @@ index_compute_xid_horizon_for_tuples(Relation irel,
    }
 
    /* determine the actual xid horizon */
-   latestRemovedXid = table_index_delete_tuples(hrel, &delstate);
+   snapshotConflictHorizon = table_index_delete_tuples(hrel, &delstate);
 
    /* assert tableam agrees that all items are deletable */
    Assert(delstate.ndeltids == nitems);
@@ -341,7 +342,7 @@ index_compute_xid_horizon_for_tuples(Relation irel,
    pfree(delstate.deltids);
    pfree(delstate.status);
 
-   return latestRemovedXid;
+   return snapshotConflictHorizon;
 }
 
 
index 5529afc1fede0e2e3e3b48cf640d94dee5c440a1..dd0f7ad2bdfc541f08f98eb664b829cea65e909d 100644 (file)
@@ -528,17 +528,17 @@ from the index immediately; since index scans only stop "between" pages,
 no scan can lose its place from such a deletion.  We separate the steps
 because we allow LP_DEAD to be set with only a share lock (it's like a
 hint bit for a heap tuple), but physically deleting tuples requires an
-exclusive lock.  We also need to generate a latestRemovedXid value for
+exclusive lock.  We also need to generate a snapshotConflictHorizon for
 each deletion operation's WAL record, which requires additional
 coordinating with the tableam when the deletion actually takes place.
-(This latestRemovedXid value may be used to generate a recovery conflict
-during subsequent REDO of the record by a standby.)
+(snapshotConflictHorizon value may be used to generate a conflict during
+subsequent REDO of the record by a standby.)
 
 Delaying and batching index tuple deletion like this enables a further
 optimization: opportunistic checking of "extra" nearby index tuples
 (tuples that are not LP_DEAD-set) when they happen to be very cheap to
 check in passing (because we already know that the tableam will be
-visiting their table block to generate a latestRemovedXid value).  Any
+visiting their table block to generate a snapshotConflictHorizon).  Any
 index tuples that turn out to be safe to delete will also be deleted.
 Simple deletion will behave as if the extra tuples that actually turn
 out to be delete-safe had their LP_DEAD bits set right from the start.
index 8b96708b3ea235d49402594c9ada045e95bf0137..65aa44893cde6a0c2b6016fbba4008c01bb05d83 100644 (file)
@@ -41,7 +41,7 @@ static BTMetaPageData *_bt_getmeta(Relation rel, Buffer metabuf);
 static void _bt_log_reuse_page(Relation rel, BlockNumber blkno,
                               FullTransactionId safexid);
 static void _bt_delitems_delete(Relation rel, Buffer buf,
-                               TransactionId latestRemovedXid,
+                               TransactionId snapshotConflictHorizon,
                                OffsetNumber *deletable, int ndeletable,
                                BTVacuumPosting *updatable, int nupdatable);
 static char *_bt_delitems_update(BTVacuumPosting *updatable, int nupdatable,
@@ -838,7 +838,7 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, FullTransactionId safexid)
    /* XLOG stuff */
    xlrec_reuse.locator = rel->rd_locator;
    xlrec_reuse.block = blkno;
-   xlrec_reuse.latestRemovedFullXid = safexid;
+   xlrec_reuse.snapshotConflictHorizon = safexid;
 
    XLogBeginInsert();
    XLogRegisterData((char *) &xlrec_reuse, SizeOfBtreeReusePage);
@@ -1156,7 +1156,7 @@ _bt_pageinit(Page page, Size size)
  * (a version that lacks the TIDs that are to be deleted).
  *
  * We record VACUUMs and b-tree deletes differently in WAL.  Deletes must
- * generate their own latestRemovedXid by accessing the table directly,
+ * generate their own snapshotConflictHorizon directly from the tableam,
  * whereas VACUUMs rely on the initial VACUUM table scan performing
  * WAL-logging that takes care of the issue for the table's indexes
  * indirectly.  Also, we remove the VACUUM cycle ID from pages, which b-tree
@@ -1287,13 +1287,14 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
  * (a version that lacks the TIDs that are to be deleted).
  *
  * This is nearly the same as _bt_delitems_vacuum as far as what it does to
- * the page, but it needs its own latestRemovedXid from caller (caller gets
- * this from tableam).  This is used by the REDO routine to generate recovery
+ * the page, but it needs its own snapshotConflictHorizon (caller gets this
+ * from tableam).  This is used by the REDO routine to generate recovery
  * conflicts.  The other difference is that only _bt_delitems_vacuum will
  * clear page's VACUUM cycle ID.
  */
 static void
-_bt_delitems_delete(Relation rel, Buffer buf, TransactionId latestRemovedXid,
+_bt_delitems_delete(Relation rel, Buffer buf,
+                   TransactionId snapshotConflictHorizon,
                    OffsetNumber *deletable, int ndeletable,
                    BTVacuumPosting *updatable, int nupdatable)
 {
@@ -1357,7 +1358,7 @@ _bt_delitems_delete(Relation rel, Buffer buf, TransactionId latestRemovedXid,
        XLogRecPtr  recptr;
        xl_btree_delete xlrec_delete;
 
-       xlrec_delete.latestRemovedXid = latestRemovedXid;
+       xlrec_delete.snapshotConflictHorizon = snapshotConflictHorizon;
        xlrec_delete.ndeleted = ndeletable;
        xlrec_delete.nupdated = nupdatable;
 
@@ -1529,7 +1530,7 @@ _bt_delitems_delete_check(Relation rel, Buffer buf, Relation heapRel,
                          TM_IndexDeleteOp *delstate)
 {
    Page        page = BufferGetPage(buf);
-   TransactionId latestRemovedXid;
+   TransactionId snapshotConflictHorizon;
    OffsetNumber postingidxoffnum = InvalidOffsetNumber;
    int         ndeletable = 0,
                nupdatable = 0;
@@ -1537,11 +1538,11 @@ _bt_delitems_delete_check(Relation rel, Buffer buf, Relation heapRel,
    BTVacuumPosting updatable[MaxIndexTuplesPerPage];
 
    /* Use tableam interface to determine which tuples to delete first */
-   latestRemovedXid = table_index_delete_tuples(heapRel, delstate);
+   snapshotConflictHorizon = table_index_delete_tuples(heapRel, delstate);
 
-   /* Should not WAL-log latestRemovedXid unless it's required */
-   if (!XLogStandbyInfoActive() || !RelationNeedsWAL(rel))
-       latestRemovedXid = InvalidTransactionId;
+   /* Should not WAL-log snapshotConflictHorizon unless it's required */
+   if (!XLogStandbyInfoActive())
+       snapshotConflictHorizon = InvalidTransactionId;
 
    /*
     * Construct a leaf-page-wise description of what _bt_delitems_delete()
@@ -1683,8 +1684,8 @@ _bt_delitems_delete_check(Relation rel, Buffer buf, Relation heapRel,
    }
 
    /* Physically delete tuples (or TIDs) using deletable (or updatable) */
-   _bt_delitems_delete(rel, buf, latestRemovedXid, deletable, ndeletable,
-                       updatable, nupdatable);
+   _bt_delitems_delete(rel, buf, snapshotConflictHorizon,
+                       deletable, ndeletable, updatable, nupdatable);
 
    /* be tidy */
    for (int i = 0; i < nupdatable; i++)
index ad489e33b3791279d42acc16a2879d069a64d332..3e311a98a6b9580e9f9231966014e6d16113fcb5 100644 (file)
@@ -668,7 +668,8 @@ btree_xlog_delete(XLogReaderState *record)
 
        XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
 
-       ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rlocator);
+       ResolveRecoveryConflictWithSnapshot(xlrec->snapshotConflictHorizon,
+                                           rlocator);
    }
 
    /*
@@ -991,7 +992,7 @@ btree_xlog_newroot(XLogReaderState *record)
  * xl_btree_reuse_page record at the point that a page is actually recycled
  * and reused for an entirely unrelated page inside _bt_split().  These
  * records include the same safexid value from the original deleted page,
- * stored in the record's latestRemovedFullXid field.
+ * stored in the record's snapshotConflictHorizon field.
  *
  * The GlobalVisCheckRemovableFullXid() test in BTPageIsRecyclable() is used
  * to determine if it's safe to recycle a page.  This mirrors our own test:
@@ -1005,7 +1006,7 @@ btree_xlog_reuse_page(XLogReaderState *record)
    xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) XLogRecGetData(record);
 
    if (InHotStandby)
-       ResolveRecoveryConflictWithSnapshotFullXid(xlrec->latestRemovedFullXid,
+       ResolveRecoveryConflictWithSnapshotFullXid(xlrec->snapshotConflictHorizon,
                                                   xlrec->locator);
 }
 
index 7dd3c1d500fd82475b98ff739602ef6dd6130c34..97f3520abbcd9555fd3d73a1e3bbf3054490b7a7 100644 (file)
@@ -26,18 +26,18 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
 static void
 out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
 {
-   appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%u",
+   appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u",
                     xlrec->locator.spcOid, xlrec->locator.dbOid,
                     xlrec->locator.relNumber, xlrec->block,
-                    EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
-                    XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+                    EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
+                    XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
 }
 
 static void
 out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
 {
-   appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
-                    xlrec->latestRemovedXid, xlrec->ntodelete);
+   appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u",
+                    xlrec->snapshotConflictHorizon, xlrec->ntodelete);
 }
 
 static void
index ef443bdb16c0f64df4752d4671c5466b24722c30..a5b861bdadef546e62da2fe1ae8473c3c58c0afa 100644 (file)
@@ -113,9 +113,9 @@ hash_desc(StringInfo buf, XLogReaderState *record)
            {
                xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec;
 
-               appendStringInfo(buf, "ntuples %d, latestRemovedXid %u",
+               appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %u",
                                 xlrec->ntuples,
-                                xlrec->latestRemovedXid);
+                                xlrec->snapshotConflictHorizon);
                break;
            }
    }
index 3f8c5e63f3bef86b3e7bc71ea7a4d558ebe79f99..325aee93ff8d13b52a3a56f47e11ba8257392820 100644 (file)
@@ -125,8 +125,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
    {
        xl_heap_prune *xlrec = (xl_heap_prune *) rec;
 
-       appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
-                        xlrec->latestRemovedXid,
+       appendStringInfo(buf, "snapshotConflictHorizon %u nredirected %u ndead %u",
+                        xlrec->snapshotConflictHorizon,
                         xlrec->nredirected,
                         xlrec->ndead);
    }
@@ -140,15 +140,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
    {
        xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
 
-       appendStringInfo(buf, "latestRemovedXid %u nplans %u",
-                        xlrec->latestRemovedXid, xlrec->nplans);
+       appendStringInfo(buf, "snapshotConflictHorizon %u nplans %u",
+                        xlrec->snapshotConflictHorizon, xlrec->nplans);
    }
    else if (info == XLOG_HEAP2_VISIBLE)
    {
        xl_heap_visible *xlrec = (xl_heap_visible *) rec;
 
-       appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
-                        xlrec->cutoff_xid, xlrec->flags);
+       appendStringInfo(buf, "snapshotConflictHorizon %u flags 0x%02X",
+                        xlrec->snapshotConflictHorizon, xlrec->flags);
    }
    else if (info == XLOG_HEAP2_MULTI_INSERT)
    {
index 4843cd530dff6b026a6d1206b08f4fc49f65c55f..f4a70d54e62b4af0328203931a7ecc68de8641f1 100644 (file)
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
            {
                xl_btree_delete *xlrec = (xl_btree_delete *) rec;
 
-               appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
-                                xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+               appendStringInfo(buf, "snapshotConflictHorizon %u; ndeleted %u; nupdated %u",
+                                xlrec->snapshotConflictHorizon,
+                                xlrec->ndeleted, xlrec->nupdated);
                break;
            }
        case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -100,11 +101,11 @@ btree_desc(StringInfo buf, XLogReaderState *record)
            {
                xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
 
-               appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%u",
+               appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%u",
                                 xlrec->locator.spcOid, xlrec->locator.dbOid,
                                 xlrec->locator.relNumber,
-                                EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
-                                XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+                                EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
+                                XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
                break;
            }
        case XLOG_BTREE_META_CLEANUP:
index d5d921a42a19b7487611f8d47d56762b7a6fd775..308bd3e27fa4601688ea3f1a9fda4e9f2c77f19f 100644 (file)
@@ -118,10 +118,10 @@ spg_desc(StringInfo buf, XLogReaderState *record)
            {
                spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec;
 
-               appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, newestredirectxid: %u",
+               appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u",
                                 xlrec->nToPlaceholder,
                                 xlrec->firstPlaceholder,
-                                xlrec->newestRedirectXid);
+                                xlrec->snapshotConflictHorizon);
            }
            break;
    }
index 00496305320e5bd923293c11cc3e1c939e875e0e..ad90b213b9cbe39d460002ca7479b8d831e9be69 100644 (file)
@@ -504,7 +504,7 @@ vacuumRedirectAndPlaceholder(Relation index, Buffer buffer)
    GlobalVisState *vistest;
 
    xlrec.nToPlaceholder = 0;
-   xlrec.newestRedirectXid = InvalidTransactionId;
+   xlrec.snapshotConflictHorizon = InvalidTransactionId;
 
    /* XXX: providing heap relation would allow more pruning */
    vistest = GlobalVisTestFor(NULL);
@@ -533,9 +533,9 @@ vacuumRedirectAndPlaceholder(Relation index, Buffer buffer)
            opaque->nPlaceholder++;
 
            /* remember newest XID among the removed redirects */
-           if (!TransactionIdIsValid(xlrec.newestRedirectXid) ||
-               TransactionIdPrecedes(xlrec.newestRedirectXid, dt->xid))
-               xlrec.newestRedirectXid = dt->xid;
+           if (!TransactionIdIsValid(xlrec.snapshotConflictHorizon) ||
+               TransactionIdPrecedes(xlrec.snapshotConflictHorizon, dt->xid))
+               xlrec.snapshotConflictHorizon = dt->xid;
 
            ItemPointerSetInvalid(&dt->pointer);
 
index 4c9f4020ff89beefa4559c332f7303c82d593f7a..44adc2098f9402f109ae81034eccba6ab8d2c541 100644 (file)
@@ -875,14 +875,11 @@ spgRedoVacuumRedirect(XLogReaderState *record)
     */
    if (InHotStandby)
    {
-       if (TransactionIdIsValid(xldata->newestRedirectXid))
-       {
-           RelFileLocator locator;
+       RelFileLocator locator;
 
-           XLogRecGetBlockTag(record, 0, &locator, NULL, NULL);
-           ResolveRecoveryConflictWithSnapshot(xldata->newestRedirectXid,
-                                               locator);
-       }
+       XLogRecGetBlockTag(record, 0, &locator, NULL, NULL);
+       ResolveRecoveryConflictWithSnapshot(xldata->snapshotConflictHorizon,
+                                           locator);
    }
 
    if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
index 9e8b6756fe02904ee364440b23aa09a840ac27af..283517d95666c84a18197a57945d8676340270ac 100644 (file)
@@ -3337,12 +3337,17 @@ GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0,
  * GetConflictingVirtualXIDs -- returns an array of currently active VXIDs.
  *
  * Usage is limited to conflict resolution during recovery on standby servers.
- * limitXmin is supplied as either latestRemovedXid, or InvalidTransactionId
- * in cases where we cannot accurately determine a value for latestRemovedXid.
+ * limitXmin is supplied as either a cutoff with snapshotConflictHorizon
+ * semantics, or InvalidTransactionId in cases where caller cannot accurately
+ * determine a safe snapshotConflictHorizon value.
  *
  * If limitXmin is InvalidTransactionId then we want to kill everybody,
  * so we're not worried if they have a snapshot or not, nor does it really
- * matter what type of lock we hold.
+ * matter what type of lock we hold.  Caller must avoid calling here with
+ * snapshotConflictHorizon style cutoffs that were set to InvalidTransactionId
+ * during original execution, since that actually indicates that there is
+ * definitely no need for a recovery conflict (the snapshotConflictHorizon
+ * convention for InvalidTransactionId values is the opposite of our own!).
  *
  * All callers that are checking xmins always now supply a valid and useful
  * value for limitXmin. The limitXmin is always lower than the lowest
index 7db86f7885f564b37fe876713753d649e510e3b8..f43229dfda610b0f3e0001944567bcc9d09d15b4 100644 (file)
@@ -464,8 +464,18 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
    }
 }
 
+/*
+ * Generate whatever recovery conflicts are needed to eliminate snapshots that
+ * might see XIDs <= snapshotConflictHorizon as still running.
+ *
+ * snapshotConflictHorizon cutoffs are our standard approach to generating
+ * granular recovery conflicts.  Note that InvalidTransactionId values are
+ * interpreted as "definitely don't need any conflicts" here, which is a
+ * general convention that WAL records can (and often do) depend on.
+ */
 void
-ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileLocator locator)
+ResolveRecoveryConflictWithSnapshot(TransactionId snapshotConflictHorizon,
+                                   RelFileLocator locator)
 {
    VirtualTransactionId *backends;
 
@@ -480,12 +490,11 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileLocat
     * which is sufficient for the deletion operation must take place before
     * replay of the deletion record itself).
     */
-   if (!TransactionIdIsValid(latestRemovedXid))
+   if (!TransactionIdIsValid(snapshotConflictHorizon))
        return;
 
-   backends = GetConflictingVirtualXIDs(latestRemovedXid,
+   backends = GetConflictingVirtualXIDs(snapshotConflictHorizon,
                                         locator.dbOid);
-
    ResolveRecoveryConflictWithVirtualXIDs(backends,
                                           PROCSIG_RECOVERY_CONFLICT_SNAPSHOT,
                                           WAIT_EVENT_RECOVERY_CONFLICT_SNAPSHOT,
@@ -497,7 +506,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileLocat
  * FullTransactionId values
  */
 void
-ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXid,
+ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId snapshotConflictHorizon,
                                           RelFileLocator locator)
 {
    /*
@@ -510,13 +519,13 @@ ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXi
    uint64      diff;
 
    diff = U64FromFullTransactionId(nextXid) -
-       U64FromFullTransactionId(latestRemovedFullXid);
+       U64FromFullTransactionId(snapshotConflictHorizon);
    if (diff < MaxTransactionId / 2)
    {
-       TransactionId latestRemovedXid;
+       TransactionId truncated;
 
-       latestRemovedXid = XidFromFullTransactionId(latestRemovedFullXid);
-       ResolveRecoveryConflictWithSnapshot(latestRemovedXid, locator);
+       truncated = XidFromFullTransactionId(snapshotConflictHorizon);
+       ResolveRecoveryConflictWithSnapshot(truncated, locator);
    }
 }
 
index 093bf23443c0f32d90a397f0e01282efffd524a7..a84949747b7e4acacbd7ad2a1fe88079d6a9a825 100644 (file)
@@ -441,7 +441,7 @@ extern XLogRecPtr gistXLogPageDelete(Buffer buffer,
                                     OffsetNumber downlinkOffset);
 
 extern void gistXLogPageReuse(Relation rel, BlockNumber blkno,
-                             FullTransactionId latestRemovedXid);
+                             FullTransactionId deleteXid);
 
 extern XLogRecPtr gistXLogUpdate(Buffer buffer,
                                 OffsetNumber *todelete, int ntodelete,
@@ -449,7 +449,7 @@ extern XLogRecPtr gistXLogUpdate(Buffer buffer,
                                 Buffer leftchildbuf);
 
 extern XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete,
-                                int ntodelete, TransactionId latestRemovedXid);
+                                int ntodelete, TransactionId snapshotConflictHorizon);
 
 extern XLogRecPtr gistXLogSplit(bool page_is_leaf,
                                SplitedPageLayout *dist,
index 9bbe4c2622071ec58b94ffccf646634d3f4082bf..33f1c7e31b159f3747831b949e7781f219aea637 100644 (file)
@@ -49,7 +49,7 @@ typedef struct gistxlogPageUpdate
  */
 typedef struct gistxlogDelete
 {
-   TransactionId latestRemovedXid;
+   TransactionId snapshotConflictHorizon;
    uint16      ntodelete;      /* number of deleted offsets */
 
    /*
@@ -99,10 +99,10 @@ typedef struct gistxlogPageReuse
 {
    RelFileLocator locator;
    BlockNumber block;
-   FullTransactionId latestRemovedFullXid;
+   FullTransactionId snapshotConflictHorizon;
 } gistxlogPageReuse;
 
-#define SizeOfGistxlogPageReuse    (offsetof(gistxlogPageReuse, latestRemovedFullXid) + sizeof(FullTransactionId))
+#define SizeOfGistxlogPageReuse    (offsetof(gistxlogPageReuse, snapshotConflictHorizon) + sizeof(FullTransactionId))
 
 extern void gist_redo(XLogReaderState *record);
 extern void gist_desc(StringInfo buf, XLogReaderState *record);
index 59230706bb0be764926f8a43a7425263e592e405..6dafb4a59835a6c5fb65c091bc952c65f41350c1 100644 (file)
@@ -250,7 +250,7 @@ typedef struct xl_hash_init_bitmap_page
  */
 typedef struct xl_hash_vacuum_one_page
 {
-   TransactionId latestRemovedXid;
+   TransactionId snapshotConflictHorizon;
    int         ntuples;
 
    /* TARGET OFFSET NUMBERS FOLLOW AT THE END */
index bbf164719e1efffdbbe2609ed67815dfe9371f02..5c77290eecff70f087381cba02887c2784f436bf 100644 (file)
@@ -242,7 +242,7 @@ typedef struct xl_heap_update
  */
 typedef struct xl_heap_prune
 {
-   TransactionId latestRemovedXid;
+   TransactionId snapshotConflictHorizon;
    uint16      nredirected;
    uint16      ndead;
    /* OFFSET NUMBERS are in the block reference 0 */
@@ -342,7 +342,7 @@ typedef struct xl_heap_freeze_plan
  */
 typedef struct xl_heap_freeze_page
 {
-   TransactionId latestRemovedXid;
+   TransactionId snapshotConflictHorizon;
    uint16      nplans;
 
    /* FREEZE PLANS FOLLOW */
@@ -359,7 +359,7 @@ typedef struct xl_heap_freeze_page
  */
 typedef struct xl_heap_visible
 {
-   TransactionId cutoff_xid;
+   TransactionId snapshotConflictHorizon;
    uint8       flags;
 } xl_heap_visible;
 
@@ -396,8 +396,8 @@ typedef struct xl_heap_rewrite_mapping
    XLogRecPtr  start_lsn;      /* Insert LSN at begin of rewrite */
 } xl_heap_rewrite_mapping;
 
-extern void HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
-                                                  TransactionId *latestRemovedXid);
+extern void HeapTupleHeaderAdvanceConflictHorizon(HeapTupleHeader tuple,
+                                                 TransactionId *snapshotConflictHorizon);
 
 extern void heap_redo(XLogReaderState *record);
 extern void heap_desc(StringInfo buf, XLogReaderState *record);
@@ -409,6 +409,8 @@ extern const char *heap2_identify(uint8 info);
 extern void heap_xlog_logical_rewrite(XLogReaderState *r);
 
 extern XLogRecPtr log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer,
-                                  Buffer vm_buffer, TransactionId cutoff_xid, uint8 vmflags);
+                                  Buffer vm_buffer,
+                                  TransactionId snapshotConflictHorizon,
+                                  uint8 vmflags);
 
 #endif                         /* HEAPAM_XLOG_H */
index dd504d1885119ad876867daeb56091d365356471..3b2d959c69844237a1e7d18741700afb96d033d9 100644 (file)
@@ -187,7 +187,7 @@ typedef struct xl_btree_reuse_page
 {
    RelFileLocator locator;
    BlockNumber block;
-   FullTransactionId latestRemovedFullXid;
+   FullTransactionId snapshotConflictHorizon;
 } xl_btree_reuse_page;
 
 #define SizeOfBtreeReusePage   (sizeof(xl_btree_reuse_page))
@@ -199,7 +199,7 @@ typedef struct xl_btree_reuse_page
  * when btinsert() is called.
  *
  * The records are very similar.  The only difference is that xl_btree_delete
- * has to include a latestRemovedXid field to generate recovery conflicts.
+ * has a snapshotConflictHorizon field to generate recovery conflicts.
  * (VACUUM operations can just rely on earlier conflicts generated during
  * pruning of the table whose TIDs the to-be-deleted index tuples point to.
  * There are also small differences between each REDO routine that we don't go
@@ -232,7 +232,7 @@ typedef struct xl_btree_vacuum
 
 typedef struct xl_btree_delete
 {
-   TransactionId latestRemovedXid;
+   TransactionId snapshotConflictHorizon;
    uint16      ndeleted;
    uint16      nupdated;
 
index 930ffdd4f7ec7b312b255ff3174e2f97d7ec22d9..82332cb694b573bb734d8d5b0e5fbb9a40031d94 100644 (file)
@@ -239,7 +239,7 @@ typedef struct spgxlogVacuumRedirect
 {
    uint16      nToPlaceholder; /* number of redirects to make placeholders */
    OffsetNumber firstPlaceholder;  /* first placeholder tuple to remove */
-   TransactionId newestRedirectXid;    /* newest XID of removed redirects */
+   TransactionId snapshotConflictHorizon;  /* newest XID of removed redirects */
 
    /* offsets of redirect tuples to make placeholders follow */
    OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
index e45d73eae3cd625252e76165eaa6de035daba467..4d1ef405c22d7f36df2a701f34aab4381eb92f65 100644 (file)
@@ -1318,7 +1318,7 @@ table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
  * marked as deletable.  See comments above TM_IndexDelete and comments above
  * TM_IndexDeleteOp for full details.
  *
- * Returns a latestRemovedXid transaction ID that caller generally places in
+ * Returns a snapshotConflictHorizon transaction ID that caller places in
  * its index deletion WAL record.  This might be used during subsequent REDO
  * of the WAL record when in Hot Standby mode -- a recovery conflict for the
  * index deletion operation might be required on the standby.
index f5da98dc73626285d9cd67ead7d4452184b89b8a..e46c934c56d8cdd50ec1787f9ab08da1cf6b277b 100644 (file)
@@ -29,9 +29,9 @@ extern PGDLLIMPORT bool log_recovery_conflict_waits;
 extern void InitRecoveryTransactionEnvironment(void);
 extern void ShutdownRecoveryTransactionEnvironment(void);
 
-extern void ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid,
+extern void ResolveRecoveryConflictWithSnapshot(TransactionId snapshotConflictHorizon,
                                                RelFileLocator locator);
-extern void ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXid,
+extern void ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId snapshotConflictHorizon,
                                                       RelFileLocator locator);
 extern void ResolveRecoveryConflictWithTablespace(Oid tsid);
 extern void ResolveRecoveryConflictWithDatabase(Oid dbid);