Re: Bug? pg_rewind produces unusable but starting database with standby recovery

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bug? pg_rewind produces unusable but starting database with standby recovery
Date: 2026-05-15 09:50:44
Message-ID: CAN4CZFPRVCNv8-qgEexxJhfLCvssRPrx7uL5JyDnYc98wdQqaA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!

I want to add one slightly related issue to the thread, attached as
0002. The patches are independent, one can be applied without the
other. The only relation is that we found 0002 because of the changes
in 0001. After reviewing the details, however, I believe 0002 isn't a
regression caused by 0001, but rather a previously hidden bug that
0001 exposed.

Sometimes pg_rewind can generate a state where the stated
minRecoveryPoint is beyond the actual available wal. In the original
recovery checks, postgres simply continued on this point. With the
modified 0001 version, it detects that we didn't reach the stated
minRecoveryPoint and reports an error.

Regardless of 0001, pg_rewind shouldn't result in inconsistent output
like that. The attached 0002 aims to solve this by capturing the
expected minRecoveryPoint earlier, before traversing the wal files.
The previous, opposite order could add new segment files between
retrieving the file list and querying the LSN, which results in
missing WAL data in the output.

Attachment Content-Type Size
0002-pg_rewind-fix-remote-source-WAL-race-condition.patch application/octet-stream 12.8 KB
0001-Enforce-minRecoveryPoint-check-regardless-of-archive.patch application/octet-stream 10.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-05-15 09:56:58 Re: Improve conflict detection when replication origins are reused
Previous Message Fujii Masao 2026-05-15 09:36:21 Re: [PATCH] Fix psql tab completion for REPACK boolean options