Commits on Aug 6, 2026
-
Fix the race condition of updating slot minimum LSN
Previously, there is a race condition: if a backend creates a new slot and attempts to initialize the slot.restart_lsn during WAL reservation, but meanwhile, another backend invokes ReplicationSlotsComputeRequiredLSN(), the slot minimum LSN may be initially updated by the newly created slot, only to be subsequently overwritten by the backend running ReplicationSlotsComputeRequiredLSN() with an more recent LSN. This scenario could lead to the premature removal of WALs reserved by the new slot during a checkpoint, resulting in the newly created slot being invalidated. The commit closes this race condition by acquiring an exclusive ReplicationSlotControlLock when updating slot.restart_lsn during WAL reservation. Additionally, XLogSetReplicationSlotMinimumLSN() is placed under the protection of the ReplicationSlotControlLock. This serializes the update of slot.restart_lsn and the computation of the minimum LSN in other backends, ensuring that a more recent minimum LSN isn't computed while an older one is still being reserved.
authored and Commitfest Bot committed
Aug 6, 2026