Re: how to identify the timeline of specified recovery_target_timewhen do multiple PITR - Mailing list pgsql-general

From magodo
Subject Re: how to identify the timeline of specified recovery_target_timewhen do multiple PITR
Date
Msg-id c73ac63988c2a162b9842ad7b5d394387c3703a1.camel@sina.com
Whole thread Raw
In response to Re: how to identify the timeline of specified recovery_target_timewhen do multiple PITR  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: how to identify the timeline of specified recovery_target_timewhen do multiple PITR  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-general
On Wed, 2018-10-03 at 08:06 +0200, Laurenz Albe wrote:
> magodo wrote:
> > I read the document about recovery configuration, it says:
> 
> [...]
> 
> > Therefore, suppose I am going to recover to a point of some child
> > timeline, to identify the point, I have to specify either
> > recovery_target_name or recovery_target_time, and also specify the
> > recovery_target_timeline.
> > 
> > It is more like a tuple like (recovery_target_time,
> > recovery_target_timeline), that specify a real point among all
> > history
> > branches. Am I understand this correctly?
> 
> I think you understood the concept well enough.
> 
> > If yes, what I want to ask is that, though the timeline is
> > increasing
> > between different recovery, but each timestamp corresponds to a
> > timeline ID, one by one. So if I get a recovery_target_time, why
> > should
> > I still specify the recovery_target_timeline? 
> > 
> > Suppose following illustration:
> > 
> >          A     B
> > BASE-----+-----+------o1 (recover to
> > A)                              1
> >          |     |           C
> >          +.....|.......----+---o2 (regret, recover to
> > B)             2
> >                |           |    
> >                +...........|..------o3 (regret again, recover to
> > C)  3
> >                            | 
> >                            +........--
> > --                             4
> 
> Consider this       ^   point in time.
>                     |
> 
> Suppose you specify this point in time as recovery_target_time.
> 
> Then it is not clear which of the timelines you want to follow.
> The point of time exists in timeline 1, 2 and 3.
> 
> In other words, should recovery use the WAL from
> 0000000100000ABC00000012, 0000000200000ABC00000012 or
> 0000000300000ABC00000012?
> 
> By default, recovery will stay on the timeline where it started.
> If you want to go to timeline 2 or 3, you have to specify
> recovery_target_timeline.
> 
> Yours,
> Laurenz Albe

For me, the specified point corresponds to timeline 1, because at that
time, the timeline is 1 indeed (when there is no timeline 2 branched
out yet). 

So in other word, my expectation is like I want to get the first
timeline which covers the specified time.

As you mentioned, there is no active timeline concept in postgres, then
what is the best practice to meet my expectation? Do I have to somehow
record the timestamp when archived wal's timeline has been changed,
then compare the specified recovery target time with those records to
find the first timeline which covers that time?

Thank you in anticipation!

---
Magodo




pgsql-general by date:

Previous
From: mo jia
Date:
Subject: Question about advance confirmed_flush_lsn using logic replicationslot when there is no modification.
Next
From: Andrew Gierth
Date:
Subject: Re: SELECT UNION into a text[]