Re: Simplify standby state machine a bit in WaitForWALToBecomeAvailable()

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Simplify standby state machine a bit in WaitForWALToBecomeAvailable()
Date: 2022-10-26 04:12:50
Message-ID: CALj2ACVvmhpw1_b+BEYv6fKiDW_A+mEoWVKgp-LiwRD4KnW2VA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 18, 2022 at 1:03 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:
>
> On Tue, Oct 18, 2022 at 12:01 PM Bharath Rupireddy
> <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > In standby mode, the state machine in WaitForWALToBecomeAvailable()
> > reads WAL from pg_wal after failing to read from the archive. This is
> > currently implemented in XLogFileReadAnyTLI() by calling
> > XLogFileRead() with source XLOG_FROM_PG_WAL after it fails with source
> > XLOG_FROM_PG_ARCHIVE and the current source isn't changed at all.
> > Also, passing the source to XLogFileReadAnyTLI() in
> > WaitForWALToBecomeAvailable() isn't straight i.e. it's not necessary
> > to pass in XLOG_FROM_ANY at all. These things make the state machine a
> > bit complicated and hard to understand.
> >
> > The attached patch attempts to simplify the code a bit by changing the
> > current source to XLOG_FROM_PG_WAL after failing in
> > XLOG_FROM_PG_ARCHIVE so that the state machine can move smoothly to
> > read from pg_wal. And we can just pass the current source to
> > XLogFileReadAnyTLI(). It also enables us to reduce a bit of extra
> > XLogFileRead() code in XLogFileReadAnyTLI().
> >
> > Thoughts?
>
> +1

Thanks. Let's see what others think about it. I will add a CF entry in a while.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-10-26 04:15:05 Re: Allow file inclusion in pg_hba and pg_ident files
Previous Message Julien Rouhaud 2022-10-26 03:19:48 Re: Allow file inclusion in pg_hba and pg_ident files