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

From: Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>
To: Stepan Neretin <slpmcf(at)gmail(dot)com>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, 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-05 02:46:25
Message-ID: CAA3qoJnKn3-dWydK6hXOO45BMKgiBvansxaniVug1krOWZyM1w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Stepan,

Thanks for the v2 patch. I tested it locally and also instrumented
XLogSendPhysical() to
verify the walsender behavior.

In the current test, both SendRqsPtr and sentPtr are 0/00D00000.
Consequently, the walsender returnes at:

if (SendRqstPtr <= sentPtr)
{
WalSndCaughtUp = true;
return;
}

It never reaches WalSndSegmentOpen() and therefore does not attempt to open
the WAL segment involved in the race.

I also reintroduced the old unlink() behavior. The file-existence assertion
failed as expected, but the standby walsender still started successfully
and did not report a missing WAL segment.

Therefore, the test does verify that the segment remains present before the
rename, but the walsender portion does not currently exercise the
reported race. It may be better either to remove that portion or arrange
for SendRqstPtr > sentPtr so the walsender actually attempts to read the
segment.

Regards,

--
Ze Chen (Neil)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-08-05 02:49:30 Re: pgstat: Flush some statistics within running transactions, take 2
Previous Message Fujii Masao 2026-08-05 02:45:59 Re: enhance wraparound warnings