From 94b4e946cd498470e9a0fac0b15299feaccfeefc Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Thu, 31 Jul 2025 14:07:51 -0400 Subject: [PATCH v14 05/24] Rename PruneState.freeze to attempt_freeze This makes it more clear that this is to indicate the caller would like heap_page_prune_and_freeze() to consider freezing tuples -- not that we ultimately will end up freezing them. Also rename local variable hint_bit_fpi to did_tuple_hint_fpi. This makes it clear it is about tuple hints and not page hints and that it indicates something that happened and not something that could happen. And rename local variable do_hint to do_hint_prune. This distinguishes the prunable and page full hints used to decide whether or not to on-access prune a page from other page-level and tuple hint bits. --- src/backend/access/heap/pruneheap.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index ea8216e0632..740aa07cd83 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -42,7 +42,7 @@ typedef struct /* whether or not dead items can be set LP_UNUSED during pruning */ bool mark_unused_now; /* whether to attempt freezing tuples */ - bool freeze; + bool attempt_freeze; const struct VacuumCutoffs *cutoffs; /*------------------------------------------------------- @@ -361,14 +361,14 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, HeapTupleData tup; bool do_freeze; bool do_prune; - bool do_hint; - bool hint_bit_fpi; + bool do_hint_prune; + bool did_tuple_hint_fpi; int64 fpi_before = pgWalUsage.wal_fpi; /* Copy parameters to prstate */ prstate.vistest = vistest; prstate.mark_unused_now = (options & HEAP_PAGE_PRUNE_MARK_UNUSED_NOW) != 0; - prstate.freeze = (options & HEAP_PAGE_PRUNE_FREEZE) != 0; + prstate.attempt_freeze = (options & HEAP_PAGE_PRUNE_FREEZE) != 0; prstate.cutoffs = cutoffs; /* @@ -390,7 +390,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, /* initialize page freezing working state */ prstate.pagefrz.freeze_required = false; - if (prstate.freeze) + if (prstate.attempt_freeze) { Assert(new_relfrozen_xid && new_relmin_mxid); prstate.pagefrz.FreezePageRelfrozenXid = *new_relfrozen_xid; @@ -437,7 +437,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, * function, when we return the value to the caller, so that the caller * doesn't set the VM bit incorrectly. */ - if (prstate.freeze) + if (prstate.attempt_freeze) { prstate.all_visible = true; prstate.all_frozen = true; @@ -551,7 +551,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, * If checksums are enabled, heap_prune_satisfies_vacuum() may have caused * an FPI to be emitted. */ - hint_bit_fpi = fpi_before != pgWalUsage.wal_fpi; + did_tuple_hint_fpi = fpi_before != pgWalUsage.wal_fpi; /* * Process HOT chains. @@ -659,7 +659,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, * pd_prune_xid field or the page was marked full, we will update the hint * bit. */ - do_hint = ((PageHeader) page)->pd_prune_xid != prstate.new_prune_xid || + do_hint_prune = ((PageHeader) page)->pd_prune_xid != prstate.new_prune_xid || PageIsFull(page); /* @@ -667,7 +667,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, * plans we prepared, or not. */ do_freeze = false; - if (prstate.freeze) + if (prstate.attempt_freeze) { if (prstate.pagefrz.freeze_required) { @@ -702,14 +702,14 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, */ if (RelationNeedsWAL(relation)) { - if (hint_bit_fpi) + if (did_tuple_hint_fpi) do_freeze = true; else if (do_prune) { if (XLogCheckBufferNeedsBackup(buffer)) do_freeze = true; } - else if (do_hint) + else if (do_hint_prune) { if (XLogHintBitIsNeeded() && XLogCheckBufferNeedsBackup(buffer)) do_freeze = true; @@ -752,7 +752,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, /* Any error while applying the changes is critical */ START_CRIT_SECTION(); - if (do_hint) + if (do_hint_prune) { /* * Update the page's pd_prune_xid field to either zero, or the lowest @@ -893,7 +893,7 @@ heap_page_prune_and_freeze(Relation relation, Buffer buffer, presult->lpdead_items = prstate.lpdead_items; /* the presult->deadoffsets array was already filled in */ - if (prstate.freeze) + if (prstate.attempt_freeze) { if (presult->nfrozen > 0) { @@ -1475,7 +1475,7 @@ heap_prune_record_unchanged_lp_normal(Page page, PruneState *prstate, OffsetNumb } /* Consider freezing any normal tuples which will not be removed */ - if (prstate->freeze) + if (prstate->attempt_freeze) { bool totally_frozen; -- 2.43.0