Re: Do away with zero-padding assumption before WALRead() - Mailing list pgsql-hackers

From Nazir Bilal Yavuz
Subject Re: Do away with zero-padding assumption before WALRead()
Date
Msg-id CAN55FZ3xJtvk-PMxJLrX2LC+-1jkMoXK44ceGtS5JmLsCQV1Fg@mail.gmail.com
Whole thread Raw
In response to Do away with zero-padding assumption before WALRead()  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Do away with zero-padding assumption before WALRead()
List pgsql-hackers
Hi,

On Tue, 13 Feb 2024 at 09:17, Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> Hi,
>
> I noticed an assumption [1] at WALRead() call sites expecting the
> flushed WAL page to be zero-padded after the flush LSN. I think this
> can't always be true as the WAL can get flushed after determining the
> flush LSN before reading it from the WAL file using WALRead(). I've
> hacked the code up a bit to check if that's true -
> https://github.com/BRupireddy2/postgres/tree/ensure_extra_read_WAL_page_is_zero_padded_at_the_end_WIP,
> the tests hit the Assert(false); added. Which means, the zero-padding
> comment around WALRead() call sites isn't quite right.
>
> I'm wondering why the WALRead() callers are always reading XLOG_BLCKSZ
> despite knowing exactly how much to read. Is it to tell the OS to
> explicitly fetch the whole page from the disk? If yes, the OS will do
> that anyway because the page transfers from disk to OS page cache are
> always in terms of disk block sizes, no?

I am curious about the same. The page size and disk block size could
be different, so the reason could be explicitly fetching the whole
page from the disk as you said. Is this the reason or are there any
other benefits of always reading XLOG_BLCKSZ instead of reading the
sufficient part? I tried to search in older threads and code comments
but I could not find an explanation.

-- 
Regards,
Nazir Bilal Yavuz
Microsoft



pgsql-hackers by date:

Previous
From: Oleg Tselebrovskiy
Date:
Subject: Re: Returning non-terminated string in ECPG Informix-compatible function
Next
From: Peter Eisentraut
Date:
Subject: Re: Allow passing extra options to initdb for tests