1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-22 14:32:25 +03:00

Standardize rmgrdesc recovery conflict XID output.

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 <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wzm2CQUmViUq7Opgk=McVREHSOorYaAjR1ZpLYkRN7_dPw@mail.gmail.com
This commit is contained in:
Peter Geoghegan
2022-11-17 14:55:08 -08:00
parent 6ff5aa1299
commit 1489b1ce72
27 changed files with 179 additions and 150 deletions

View 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,

View 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);

View 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 */

View 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 */

View 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;

View 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];

View 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.