| From: | Stepan Neretin <slpmcf(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Fix archive restore race that could unlink WAL before rename |
| Date: | 2026-07-24 15:29:36 |
| Message-ID: | CA+Yyo5S0C25jS_pRWQiGgoiy+X=GyJS7ZJkEq=_SW1WWpkL3Sg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
KeepFileRestoredFromArchive() used to unlink an existing WAL segment
before renaming the restored file into place on non-Windows. Between
those two steps the segment is missing from pg_wal, so a concurrent
walsender (or anything else looking at that path) can observe a gap.
On POSIX, durable_rename() already replaces the target atomically, so
the prior unlink is unnecessary. Windows still needs the
rename-to-.deletedN + unlink dance, so that path is unchanged.
The attached patch drops the non-Windows unlink and adds a TAP test that
uses an injection point between the old unlink site and the rename to
show the segment remains present.
Best regards,
Stepan Neretin
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-archive-restore-race-unlink-WAL-before-rename.patch | text/x-patch | 3.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2026-07-24 15:52:37 | Re: POC: PLpgSQL FOREACH IN JSON ARRAY |
| Previous Message | Stepan Neretin | 2026-07-24 15:24:36 | Re: amcheck: detect duplicate PostingItem keys in GIN posting trees |