Re: how to identify the timeline of specified recovery_target_time when do multiple PITR

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: magodo <wztdyl(at)sina(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: how to identify the timeline of specified recovery_target_time when do multiple PITR
Date: 2018-10-12 03:42:12
Message-ID: ec9fb3bf4873aa450f67556c3bbda85c8e4f1d34.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

magodo wrote:
> > How can you know how many WAL segments there are on timeline 1, and if
> > there is one that extends past 2018-10-11 12:00:00 or not?
>
> This is the exact problem I want to figure out. My approach is as you said,
> I will parse each archived WAL segment via `pg_xlogdump -r Transaction`,
> and try to find the first least earliest WAL against the specified time.
> This is a linear search, which has complexity of O(n).

That means that the time spent grows linearly, but it is still a lot of time
if there are a lot of WAL archives.

> So if you want to recover to that point of time, how do you choose the timeline?

PostgreSQL doesn't provide auch a functionality, and I can think of three reasons:
1) the high cost as mentioned above
2) during archive recovery, it does not happen very often that you have to
choose between timelines at all. It is more typical for streaming replication.
3) nobody saw a use case for such a functionality

If you really need this functionality, you'll have to write it yourself.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Abhishek Tripathi 2018-10-12 05:03:03 Re: Want to acquire lock on tables where primary of one table is foreign key on othere
Previous Message magodo 2018-10-12 02:20:43 Re: how to identify the timeline of specified recovery_target_time when do multiple PITR