Re: Improve WALRead() to suck data directly from WAL buffers when possible

From: Andres Freund <andres(at)anarazel(dot)de>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: Improve WALRead() to suck data directly from WAL buffers when possible
Date: 2024-01-22 20:12:18
Message-ID: 20240122201218.bclrdkwpmuk26fl3@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2024-01-10 19:59:29 +0530, Bharath Rupireddy wrote:
> + /*
> + * Typically, we must not read a WAL buffer page that just got
> + * initialized. Because we waited enough for the in-progress WAL
> + * insertions to finish above. However, there can exist a slight
> + * window after the above wait finishes in which the read buffer page
> + * can get replaced especially under high WAL generation rates. After
> + * all, we are reading from WAL buffers without any locks here. So,
> + * let's not count such a page in.
> + */
> + phdr = (XLogPageHeader) page;
> + if (!(phdr->xlp_magic == XLOG_PAGE_MAGIC &&
> + phdr->xlp_pageaddr == (ptr - (ptr % XLOG_BLCKSZ)) &&
> + phdr->xlp_tli == tli))
> + break;

I still think that anything that requires such checks shouldn't be
merged. It's completely bogus to check page contents for validity when we
should have metadata telling us which range of the buffers is valid and which
not.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2024-01-22 20:41:17 core dumps in auto_prewarm, tests succeed
Previous Message Andres Freund 2024-01-22 20:09:21 Re: Does redundant extension exist During faster COPY in PG16