Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5118~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5118
Choose a head ref
  • 4 commits
  • 87 files changed
  • 2 contributors

Commits on Dec 30, 2024

  1. Replace Latches with Interrupts

    The Latch was a flag, with an inter-process signalling mechanism that
    allowed a process to wait for the Latch to be set. My original vision
    for Latches was that you could have different latches for different
    things that you need to wait for, but in practice, almost all code
    used one "process latch" that was shared for all wakeups. The only
    exception was the "recoveryWakeupLatch". I think the reason that we
    ended up just sharing the same latch for all wakeups is that it was
    cumbersome in practice to deal with multiple latches. For starters,
    there was no machinery for waiting for multiple latches at the same
    time. Secondly, changing the "ownership" of a latch needed extra
    locking or other coordination. Thirdly, each inter-process latch
    needed to be initialized at postmaster startup time.
    
    This patch embraces the reality of how Latches were used, and replaces
    the Latches with a per-process interrupt mask. You can no longer
    allocate Latches in arbitrary shared memory structs and an interrupt
    is always directed at a particular process, addressed by its
    ProcNumber.  Each process has a bitmask of pending interrupts in
    PGPROC.
    
    This commit introduces two interrupt bits. INTERRUPT_GENERAL replaces
    the general-purpose per-process latch. All code that previously set a
    process's process latch now sets its INTERRUPT_GENERAL interrupt bit
    instead.
    
    The second interrupt bit, INTERRUPT_RECOVERY_CONTINUE, replaces
    recoveryWakeupLatch. With this new interface, the code can easily wait
    for the regular interrupts (INTERRUPT_GENERAL) at the same time as
    INTERRUPT_RECOVERY_CONTINUE. Previously, the code that waited on
    recoveryWakeupLatch had to resort to timeouts to react to other
    signals, because it was not possible to wait for two latches at the
    same time. Previous attempt at unifying those wakeups was in commit
    ac22929, but it was reverted in commit 00f690a because it caused
    a lot of spurious wakeups when the startup process was waiting for
    recovery conflicts. The new machinery avoids that problem by making it
    easy to wait for two interrupts at the same time.
    
    More interrupt bits are planned for followup patches, to replace the
    various ProcSignal bits, as well as ConfigReloadPending and
    ShutdownRequestPending.
    
    This also moves the WaitEventSet functions to a different source file,
    waiteventset.c. This separates the platform-dependent code waiting and
    signalling code from the platform-independent parts.
    
    Reviewed-by: Thomas Munro, Robert Haas, Álvaro Herrera
    Discussion: https://www.postgresql.org/message-id/476672e7-62f1-4cab-a822-f3a8e949dd3f@iki.fi
    hlinnaka authored and Commitfest Bot committed Dec 30, 2024
    Configuration menu
    Copy the full SHA
    3c79d0d View commit details
    Browse the repository at this point in the history
  2. Fix lost wakeup issue in logical replication launcher

    hlinnaka authored and Commitfest Bot committed Dec 30, 2024
    Configuration menu
    Copy the full SHA
    532d934 View commit details
    Browse the repository at this point in the history
  3. Use INTERRUPT_GENERAL for bgworker state change notification

    As part of a project to remove the reliance on PIDs to identify
    backends, backends that register dynamic background workers will now
    receive INTERRUPT_GENERAL sent directly by the postmaster when the
    worker state changes.  Previously, the postmaster would send a SIGUSR1
    signal, which relied on the ProcSignal system's handler setting the
    interrupt flag, with the same end effect.  Now that intermediate step
    is skipped.
    
    The field bgw_notify_pid still exists for backwards compatibility, but
    has no effect and may be removed in a later release.
    RegisterBackgroundWorker() now automatically assumes that the caller
    would like state change notifications delivered to its proc number,
    unless BGW_NO_NOTIFY is set in bgw_flags.
    
    Removing other cases of PIDs from the bgworker API is left for later
    work; this patch is concerned only with removing a dependency on
    ProcSignal infrastructure that is due to be removed by a later commit.
    
    This represents the first use of SendInterrupt() in the postmaster.
    It might seem more natural to use condition variables in the
    wait-for-state-change functions, so that anyone with a handle can
    wait, but condition variables as currently implemented would be a lot
    less robust than simple interrupts.
    
    Author: Thomas Munro <thomas.munro@gmail.com>
    Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
    Discussion: https://postgr.es/m/CA%2BhUKG%2B3MkS21yK4jL4cgZywdnnGKiBg0jatoV6kzaniBmcqbQ%40mail.gmail.com
    hlinnaka authored and Commitfest Bot committed Dec 30, 2024
    Configuration menu
    Copy the full SHA
    cac1de6 View commit details
    Browse the repository at this point in the history
  4. [CF 51/5118] v5 - SendProcSignal(), SetLatch() → SendInterrupt()

    This commit was automatically generated by a robot at cfbot.cputube.org.
    It is based on patches submitted to the PostgreSQL mailing lists and
    registered in the PostgreSQL Commitfest application.
    
    This branch will be overwritten each time a new patch version is posted to
    the email thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Commitfest entry: https://commitfest.postgresql.org/51/5118
    Patch(es): https://www.postgresql.org/message-id/4ddab51d-e932-40c5-b6fa-18c52db0e082@iki.fi
    Author(s): Heikki Linnakangas, Thomas Munro
    Commitfest Bot committed Dec 30, 2024
    Configuration menu
    Copy the full SHA
    be1e1a3 View commit details
    Browse the repository at this point in the history
Loading