Zhijie Hou · GitHub

Commits on Aug 6, 2026

  1. 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.

    Zhijie Hou Commitfest Bot

    authored and Commitfest Bot committed

    Aug 6, 2026
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Read the original on github.com ↗