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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Simplify standby state machine a bit in WaitForWALToBecomeAvailable()
Date: 2023-03-01 08:15:56
Message-ID: Y/8JvOfONlGJ/Ap+@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 03, 2023 at 02:53:10PM +0530, Bharath Rupireddy wrote:
> The proposed patch makes the inherent state change to pg_wal after
> failure to read from archive in XLogFileReadAnyTLI() to explicit by
> setting currentSource to XLOG_FROM_PG_WAL in the state machine. I
> think it doesn't alter the existing state machine or add any new extra
> lookups in pg_wal.

Well, did you notice 4d894b41? It introduced this change:

- readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2, currentSource);
+ readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2,
+ currentSource == XLOG_FROM_ARCHIVE ? XLOG_FROM_ANY :
+ currentSource);

And this patch basically undoes that, meaning that we would basically
look at the archives first for all the expected TLIs, but only if no
files were found in pg_wal/.

The change is subtle, see XLogFileReadAnyTLI(). On HEAD we go through
each timeline listed and check both archives and then pg_wal/ after
the last source that failed was the archives. The patch does
something different: it checks all the timelines for the archives,
then all the timelines in pg_wal/ with two separate calls to
XLogFileReadAnyTLI().
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-03-01 08:40:07 Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Previous Message Ryo Yamaji (Fujitsu) 2023-03-01 08:12:46 The order of queues in row lock is changed (not FIFO)