Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) - Mailing list pgsql-hackers

From Alexey Makhmutov
Subject Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Date
Msg-id ead2f110-c736-48f5-99e1-023dc9acbf0b@postgrespro.ru
Whole thread Raw
In response to Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)  (Melanie Plageman <melanieplageman@gmail.com>)
Responses Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
List pgsql-hackers
Hi Melanie,

Sorry for the late note for the already committed patch, but I have a 
question on the last part of the 'heap_xlog_prune_freeze' function 
related to the FSM update (it was committed in add323d -'Eliminate 
XLOG_HEAP2_VISIBLE from vacuum phase III').

Currently it contains the following logic:
    
...
Size    freespace = 0;
...
if (BufferIsValid(buffer))
{
    if ((xlrec.flags & (XLHP_HAS_REDIRECTIONS |
                        XLHP_HAS_DEAD_ITEMS |
                        XLHP_HAS_NOW_UNUSED_ITEMS)) ||
        (vmflags & VISIBILITYMAP_VALID_BITS))
        freespace = PageGetHeapFreeSpace(BufferGetPage(buffer));
...
    UnlockReleaseBuffer(buffer);
}
...
if (freespace > 0)
    XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
...
        
My question is about the last check ('freespace > 0') - do we really 
want to call 'XLogRecordPageWithFreeSpace' only if 'freespace' is 
greater than 0? As I understand, the zero value is a perfectly valid 
output of the 'PageGetHeapFreeSpace' call (i.e. page has no space or no 
free line items while we mark all rows as frozen/visible), but with the 
current implementation we will skip FSM update in such case. Maybe we 
need to use additional flag (i.e. 'need_fsm_update'), set it before 
calling 'PageGetHeapFreeSpace' and then check before the 
'XLogRecordPageWithFreeSpace' invocation?

Thanks,
Alexey



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PG 19 release notes and authors
Next
From: Bruce Momjian
Date:
Subject: Re: PG 19 release notes and authors