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

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(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: 2023-01-03 09:52:37
Message-ID: CALj2ACXqsVVP6kCSVNp+s5JJG=py3-2DZQsGvvdHqteFKHHyYw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 31, 2022 at 12:03 AM Nathan Bossart
<nathandbossart(at)gmail(dot)com> wrote:
>
> On Tue, Oct 18, 2022 at 12:01:07PM +0530, Bharath Rupireddy wrote:
> > 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().
>
> This looks correct to me. The only thing that stood out to me was the loop
> through 'tles' in XLogFileReadyAnyTLI. With this change, we'd loop through
> the timelines for both XLOG_FROM_PG_ARCHIVE and XLOG_FROM_PG_WAL, whereas
> now we only loop through the timelines once. However, I doubt this makes
> much difference in practice. You'd only do the extra loop whenever
> restoring from the archives failed.

Right. With the patch, we'd loop again through the tles after a
failure from the archive. Since the curFileTLI isn't changed unless a
successful read, we'd read from pg_wal with tli where we earlier left
off reading from the archive. I'm not sure if this extra looping is
worth worrying about.

--
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 jian he 2023-01-03 10:27:10 128-bit integers can range only up to (2 ^ 63 -1)
Previous Message Bharath Rupireddy 2023-01-03 09:23:10 Re: Simplify standby state machine a bit in WaitForWALToBecomeAvailable()