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

2023-03-06 Thread Bharath Rupireddy
On Mon, Mar 6, 2023 at 1:26 PM Michael Paquier wrote: > > On Sat, Mar 04, 2023 at 09:47:05AM +0530, Bharath Rupireddy wrote: > > Okay, here's a patch attached. > > Thanks. > > + * When source == XLOG_FROM_ANY, this function first searches for the segment > + * with a TLI in archive first, if not

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

2023-03-05 Thread Michael Paquier
On Sat, Mar 04, 2023 at 09:47:05AM +0530, Bharath Rupireddy wrote: > Okay, here's a patch attached. Thanks. + * When source == XLOG_FROM_ANY, this function first searches for the segment + * with a TLI in archive first, if not found, it searches in pg_wal. This way, + * if there is a WAL segment

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

2023-03-03 Thread Bharath Rupireddy
On Sat, Mar 4, 2023 at 8:14 AM Bharath Rupireddy wrote: > > On Sat, Mar 4, 2023 at 8:00 AM Michael Paquier wrote: > > > > On Fri, Mar 03, 2023 at 04:33:39PM -0800, Nathan Bossart wrote: > > > Given both Bharath and I missed this, perhaps we should add a comment > > > about > > > this behavior.

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

2023-03-03 Thread Bharath Rupireddy
On Sat, Mar 4, 2023 at 8:00 AM Michael Paquier wrote: > > On Fri, Mar 03, 2023 at 04:33:39PM -0800, Nathan Bossart wrote: > > Given both Bharath and I missed this, perhaps we should add a comment about > > this behavior. > > Makes sense to me to document that in a better way. What about the >

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

2023-03-03 Thread Michael Paquier
On Fri, Mar 03, 2023 at 04:33:39PM -0800, Nathan Bossart wrote: > Given both Bharath and I missed this, perhaps we should add a comment about > this behavior. Makes sense to me to document that in a better way. What about the addition of a short paragraph at the top of XLogFileReadAnyTLI() that

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

2023-03-03 Thread Nathan Bossart
On Fri, Mar 03, 2023 at 01:38:38PM +0530, Bharath Rupireddy wrote: > On Wed, Mar 1, 2023 at 1:46 PM Michael Paquier wrote: >> Well, did you notice 4d894b41? It introduced this change: >> >> - readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2, >> currentSource); >> +

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

2023-03-03 Thread Michael Paquier
On Fri, Mar 03, 2023 at 01:38:38PM +0530, Bharath Rupireddy wrote: > I will withdraw the patch proposed in this thread. Okay, thanks for confirming. -- Michael signature.asc Description: PGP signature

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

2023-03-03 Thread Bharath Rupireddy
On Wed, Mar 1, 2023 at 1:46 PM Michael Paquier wrote: > > 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

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

2023-03-01 Thread Michael Paquier
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

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

2023-01-05 Thread Bharath Rupireddy
On Wed, Jan 4, 2023 at 12:03 AM Nathan Bossart wrote: > > On Tue, Jan 03, 2023 at 02:53:10PM +0530, Bharath Rupireddy wrote: > > In summary: > > the flow when the standby is in crash recovery is pg_wal -> [archive > > -> pg_wal -> stream] -> [archive -> pg_wal -> stream] -> [] -> [] ... > > the

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

2023-01-03 Thread Nathan Bossart
On Tue, Jan 03, 2023 at 02:53:10PM +0530, Bharath Rupireddy wrote: > In summary: > the flow when the standby is in crash recovery is pg_wal -> [archive > -> pg_wal -> stream] -> [archive -> pg_wal -> stream] -> [] -> [] ... > the flow when the standby is in archive recovery is [archive -> pg_wal >

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

2023-01-03 Thread Bharath Rupireddy
On Sat, Dec 31, 2022 at 12:03 AM Nathan Bossart 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

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

2023-01-03 Thread Bharath Rupireddy
On Tue, Jan 3, 2023 at 7:47 AM Michael Paquier wrote: > > On Fri, Dec 30, 2022 at 10:32:57AM -0800, Nathan Bossart wrote: > > 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

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

2023-01-02 Thread Michael Paquier
On Fri, Dec 30, 2022 at 10:32:57AM -0800, Nathan Bossart wrote: > 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 >

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

2022-12-30 Thread Nathan Bossart
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

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

2022-10-25 Thread Bharath Rupireddy
On Tue, Oct 18, 2022 at 1:03 PM Amul Sul wrote: > > On Tue, Oct 18, 2022 at 12:01 PM Bharath Rupireddy > 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

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

2022-10-18 Thread Amul Sul
On Tue, Oct 18, 2022 at 12:01 PM Bharath Rupireddy 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

Simplify standby state machine a bit in WaitForWALToBecomeAvailable()

2022-10-18 Thread Bharath Rupireddy
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