Re: Fix archive restore race that could unlink WAL before rename

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>, Stepan Neretin <slpmcf(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix archive restore race that could unlink WAL before rename
Date: 2026-08-06 01:43:21
Message-ID: CAHGQGwHSbJnUmWCuF-QNUsGYF=iSSuzLRx1z_dLfYFwfbTu4Cw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 6, 2026 at 8:39 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Thu, Aug 06, 2026 at 07:16:43AM +0900, Michael Paquier wrote:
> > I'll do that, and likely apply the result. Another part is if this
> > should be backpatched or not, but I always find these recovery changes
> > quite stressing to do in stable branches, so for now I'd tend to just
> > do this change on HEAD, also due to the fact that we don't seem to
> > have reports about this tiny window being a problem in practice.
>
> I have added a note about the window still existing on WIN32, and
> applied the result as 1200dfd60c36 on HEAD.

Thanks for working on this!

This isn't directly related to this commit, but while reading the modified code
I found a small pre-existing issue in the WIN32 path.

In KeepFileRestoredFromArchive(), if unlink(oldpath) fails, the error message
reports xlogfpath, even though the file being removed is actually oldpath:

if (unlink(oldpath) != 0)
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not remove file \"%s\": %m",
xlogfpath)));

Should we fix that as well?

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yuefei Shi 2026-08-06 01:52:40 Re: Backup manifests accept out-of-range LSNs
Previous Message Sami Imseih 2026-08-06 01:22:55 Re: pgstat: Flush some statistics within running transactions, take 2