| From: | JoongHyuk Shin <sjh910805(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | [PATCH] Fix TOCTOU race in ReplicationSlotsComputeRequiredLSN() |
| Date: | 2026-04-17 06:50:01 |
| Message-ID: | CACSdjfMQYL3DV-3inrxdReqpFMOky4JxLbN0gTTY+qGJqrUJXw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Commit 2a5225b99d7 fixed a race in ReplicationSlotsComputeRequiredXmin()
where ReplicationSlotControlLock was released before the global xmin
update, allowing a concurrent backend to overwrite a correct value with
a stale one.
ReplicationSlotsComputeRequiredLSN() has the same problem, it releases the
lock before calling XLogSetReplicationSlotMinimumLSN(), so a stale minimum
LSN can overwrite a correct (lower) one, potentially leading to premature
WAL removal.
The attached patch moves LWLockRelease() to after the LSN update,
matching the xmin fix. Since 2a5225b99d7 was backpatched to all supported
versions, I believe this should be as well.
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Fix-TOCTOU-race-in-ReplicationSlotsComputeRequiredLS.patch | application/octet-stream | 2.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zhijie Hou (Fujitsu) | 2026-04-17 06:59:14 | RE: [PATCH] Fix TOCTOU race in ReplicationSlotsComputeRequiredLSN() |
| Previous Message | Fujii Masao | 2026-04-17 06:35:18 | Re: [doc] pg_ctl: fix wrong description for -l |