Re: Postgres restore sometimes restores to a point 2 days in the past

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Koen De Groote <kdg(dot)dev(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Postgres restore sometimes restores to a point 2 days in the past
Date: 2025-01-31 16:50:34
Message-ID: 70c20a65-4624-4509-ac6a-ef7f0119ea28@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/31/25 01:47, Koen De Groote wrote:

Comments in line.

> I'm running postgres 16.6
>
> My backup strategy is: basebackup and WAL archive. These get uploaded to
> the cloud.
>
> The restore is on an isolated machine and is performed daily. It
> downloads the basebackup, unpacks it, sets a recovery.signal, and a
> script is provided as restore_command, to download the WAL archives %f
> and unpack them into %p
>

What is the complete pg_basebackup command?

> In the script, the final unpacking is simply "gzip -dc %f > %p". The gz
> files are first checked with "gzip -t".
>
> If a WAL archive is asked that doesn't exist yet, the script naturally
> cannot find it, and exits with status code 1. This is the end of the
> recovery.

I don't understand the above.

What is determining that a particular WAL file should be asked for?

>
> There are a few tables that are known to receive new entries multiple
> times per day. However, the state of the recovery showed the latest item
> to be 2 days in the past. Checking the live DB, there are an expected
> amount of items since that ID.

How active is the primary database you are pulling from?

>
> I checked the logs, the last WAL archive that got downloaded is indeed
> the last one that was available. The one that failed to download on the
> restore machine, was uploaded to the cloud 8 minutes later, according to
> the upload logs on the live DB.

Available where?

If that was the last one available how could the subsequent one be a
failure to download?

>
> The postgres logs themselves seem perfectly normal. It logs all these
> WAL recoveries, switches the timeline, and becomes available.
>
> What could be going wrong? My main issue is that I don't know where to
> start looking, since nothing in the logs seems abnormal.
>
> Regards,
> Koen De Groote

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zwettler Markus (OIZ) 2025-01-31 16:57:54 Re: Re: could not accept ssl connection tlsv1 alert unknown ca
Previous Message Adrian Klaver 2025-01-31 16:37:24 Re: could not accept ssl connection tlsv1 alert unknown ca