Re: Startup PANIC on standby promotion due to zero-filled WAL segment

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Alena Vinter <dlaaren8(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Startup PANIC on standby promotion due to zero-filled WAL segment
Date: 2026-01-19 01:19:17
Message-ID: aW2GlZhKVcWNO1zl@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 14, 2026 at 06:38:27PM +0700, Alena Vinter wrote:
> I revisited the issue and examined the problem and the proposed solution in
> more depth. It’s now clear to me why the approach won’t work: if multiple
> timelines are discovered at once (for example, if a replica is stopped, a
> standby is promoted several times, and only then the replica resumes
> replication), the current design may copy part of an earlier timeline from
> the wrong predecessor into the current segment.

This case enforces standby to be used after an equivalent of crash
recovery. I doubt that somebody in their right mind would do that.

Assuming that they do, at quick glance, I don't quite see why the
solution of preventing the promotion request "$node_primary->promote"
would not be a bad one: we just do not want the promotion to be
acklowledged in the startup process until the first record of the
new timeline has been written down. FWIW, I have spent a couple of
minutes to look at what one solution could look like, finishing
with the ugly hack attached, for reference. It's definitely not
thought through, TBH, just to show what one idea could look like if we
have not received and written the first record of the new timeline
yet..
--
Michael

Attachment Content-Type Size
0001-Prevent-some-promotion-requests-at-recovery.patch text/x-diff 3.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-01-19 02:01:28 Re: Extended Statistics set/restore/clear functions.
Previous Message Julien Rouhaud 2026-01-19 01:07:36 Re: Cleaning up PREPARE query strings?