Requested WAL segment xxx has already been removed - Mailing list pgsql-hackers

From Japin Li
Subject Requested WAL segment xxx has already been removed
Date
Msg-id ME0P300MB044585BDF98BA673FA8DEDA2B654A@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Requested WAL segment xxx has already been removed
Re: Requested WAL segment xxx has already been removed
List pgsql-hackers
Hi all,

I recently hit an error with our streaming replication setup:

  2025-07-14 11:52:59.361 CST,"replicator","",728458,"10.9.9.74:35724",68747f1b.b1d8a,1,"START_REPLICATION",2025-07-14
11:52:59CST,3/0,0,ERROR,58P01,"requested WAL segment 00000001000000000000000C has already been
removed",,,,,,"START_REPLICATION0/C000000 TIMELINE 1",,,"standby","walsender",,0
 

It appears the requested WAL segment 00000001000000000000000C had already been
archived, and I confirmed its presence in the archive directory. However, when
the standby tried to request this file, the primary only searched for it in
pg_wal and didn't check the archive directory. I had to manually copy the
segment into pg_wal to get streaming replication working again.

My question is: Can we make the primary automatically search the archive if
restore_command is set?

I found that Fujii Masao also requested this feature [1], but it seems there
wasn't a consensus.

I've attached a script to reproduce this issue.

[1] https://www.postgresql.org/message-id/AANLkTinN%3DxsPOoaXzVFSp1OkfMDAB1f_d-F91xjEZDV8%40mail.gmail.com

-- 
Regards,
Japin Li


Attachment

pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: track needed attributes in plan nodes for executor use
Next
From: Dmitry Dolgov
Date:
Subject: Re: Changing shared_buffers without restart