Re: Track Oldest Initialized WAL Buffer Page

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Track Oldest Initialized WAL Buffer Page
Date: 2023-02-28 00:22:17
Message-ID: 20230228002217.GB1390948@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 07, 2023 at 07:30:00PM +0530, Bharath Rupireddy wrote:
> + /*
> + * Try updating oldest initialized XLog buffer page.
> + *
> + * Update it if we are initializing an XLog buffer page for the first
> + * time or if XLog buffers are full and we are wrapping around.
> + */
> + if (XLogRecPtrIsInvalid(XLogCtl->OldestInitializedPage) ||
> + (!XLogRecPtrIsInvalid(XLogCtl->OldestInitializedPage) &&
> + XLogRecPtrToBufIdx(XLogCtl->OldestInitializedPage) == nextidx))
> + {
> + Assert(XLogCtl->OldestInitializedPage < NewPageBeginPtr);
> +
> + XLogCtl->OldestInitializedPage = NewPageBeginPtr;
> + }

nitpick: I think you can simplify the conditional to

if (XLogRecPtrIsInvalid(XLogCtl->OldestInitializedPage) ||
XLogRecPtrToBufIdx(XLogCtl->OldestInitializedPage) == nextidx)

It's confusing to me that OldestInitializedPage is set to NewPageBeginPtr.
Doesn't that set it to the beginning of the newest initialized page?

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-02-28 00:37:26 Re: Non-superuser subscription owners
Previous Message Nathan Bossart 2023-02-28 00:11:56 Re: verbose mode for pg_input_error_message?