Re: Track Oldest Initialized WAL Buffer Page - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Track Oldest Initialized WAL Buffer Page
Date
Msg-id 20230228002217.GB1390948@nathanxps13
Whole thread Raw
In response to Track Oldest Initialized WAL Buffer Page  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Track Oldest Initialized WAL Buffer Page
List 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



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: verbose mode for pg_input_error_message?
Next
From: Jeff Davis
Date:
Subject: Re: Non-superuser subscription owners