Re: Is Recovery actually paused? - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: Is Recovery actually paused?
Date
Msg-id CAFiTN-utDVAnrf8AK--gTse_si7CtfNg6A8LaTWrYthCwmYE7Q@mail.gmail.com
Whole thread Raw
In response to Re: Is Recovery actually paused?  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
On Tue, Feb 9, 2021 at 7:28 AM Kyotaro Horiguchi
<horikyota.ntt@gmail.com> wrote:
>
> At Mon, 8 Feb 2021 17:05:52 +0530, Dilip Kumar <dilipbalaut@gmail.com> wrote in
> > On Mon, Feb 8, 2021 at 2:19 PM Yugo NAGATA <nagata@sraoss.co.jp> wrote:
> > >
> > > On Mon, 08 Feb 2021 17:32:46 +0900 (JST)
> > > Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
> > >
> > > > At Mon, 8 Feb 2021 14:12:35 +0900, Yugo NAGATA <nagata@sraoss.co.jp> wrote in
> > > > > > > > I think the right fix should be that the state should never go from
> > > > > > > > ‘paused’ to ‘pause requested’  so I think pg_wal_replay_pause should take
> > > > > > > > care of that.
> > > > > > >
> > > > > > > It makes sense to take care of this in pg_wal_replay_pause, but I wonder
> > > > > > > it can not handle the case that a user resume and pause again while a sleep.
> > > > > >
> > > > > > Right, we will have to check and set in the loop.  But we should not
> > > > > > allow the state to go from paused to pause requested irrespective of
> > > > > > this.
> > > > >
> > > > > I agree with you.
> > > >
> > > > Is there any actual harm if PAUSED returns to REQUESETED, assuming we
> > > > immediately change the state to PAUSE always we see REQUESTED in the
> > > > waiting loop, despite that we allow change the state from PAUSE to
> > > > REQUESTED via NOT_PAUSED between two successive loop condition checks?
> > >
> > > If a user call pg_wal_replay_pause while recovery is paused, users can
> > > observe 'pause requested' during a sleep alghough the time window is short.
> > > It seems a bit odd that pg_wal_replay_pause changes the state like this
> > > because This state meeans that recovery may not be 'paused'.
> >
> > Yeah, this appears wrong that after 'paused' we go back to 'pause
> > requested'.  the logical state transition should always be as below
> >
> > NOT PAUSED -> PAUSE REQUESTED or PAUSED (maybe we should always go to
> > request and then paused but there is nothing wrong with going to
> > paused)
> > PAUSE REQUESTED -> NOT PAUSE or PAUSED (either cancel the request or get paused)
> > PAUSED -> NOT PAUSED (from PAUSED we should not go to the
> > PAUSE_REQUESTED without going to NOT PAUSED)
>
> I didn't asked about the internal logical correctness, but asked about
> *actual harm* revealed to users. I don't see any actual harm in the
> "wrong" transition because:
>
> 1. It is not wrong nor strange that the invoker of pg_wal_replay_pause
>   sees the state PAUSE_REQUESTED before it changes to PAUSED.  Even if
>   the previous state was PAUSED, it is no business of the requestors.

The 'pg_wal_replay_pause' request to pause the recovery so it is fine
to first change the state to PAUSE_REQUESTED and then to PAUSED.  But
if the recovery is already paused then what is the point in bringing
the state back to PAUSE_REQUESTED.  For example, suppose the tool want
to raise the pause request and wait until recovery actually paused, so
if it was already paused then if we bring it back to PAUSE_REQUESTED
then it doesn't look correct and we might need to do an extra wait
cycle in the tool until it reaches back to PAUSED, I don't think that
is really a best design.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Greg Nancarrow
Date:
Subject: Re: Parallel INSERT (INTO ... SELECT ...)
Next
From: Dilip Kumar
Date:
Subject: Re: Is Recovery actually paused?