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/5997~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/5997
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Aug 31, 2025

  1. PGReserveSemaphores() called from CreateSharedMemoryAndSemaphores()

    Before e256266, PGReserveSemaphores()
    was required to be called before SpinlockSemaInit() since spinlocks may
    be implemented using semaphores on some platforms.  SpinlockSemaInit()
    was required to be called before InitShmemAllocation() since the latter
    initialized a spinlock to synchronize shared memory allocations.
    e256266 removed the call to
    SpinlockSemaInit() from CreateSharedMemoryAndSemaphores() but left the
    call to PGReserveSemaphores() in CreateSharedMemoryAndSemaphores(), even
    though it fits in CreateOrAttachShmemStructs() along with the calls to
    other functions allocating shared memory structures. Add a comment
    explaining this absurdity.
    
    To be backpatched to PG 18.
    
    Author: Ashutosh Bapat <[email protected]>
    Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
    ashutosh-bapat authored and Commitfest Bot committed Aug 31, 2025
    Configuration menu
    Copy the full SHA
    0efb953 View commit details
    Browse the repository at this point in the history
  2. Refactor shared memory allocation for semaphores

    Before e256266 spinlocks were
    implemented using semaphores on some platforms. Hence
    PGReserveSemaphores() was required to be called before
    SpinlockSemaInit().  SpinlockSemaInit() was required to be called before
    InitShmemAllocation() since the latter initialized a spinlock to
    synchronize shared memory allocations.  A cyclic dependency existed
    because PGReserveSemaphores() uses shared memory for semaphores on some
    platforms. It was broken by letting PGReserveSemaphores() allocate
    shared memory without a spinlock using ShmemAllocUnlocked().  After
    e256266, spinlocks are not implemented
    using semaphores at all. This allows us to eliminate the need to
    estimate and allocate shared memory required by semaphores specially and
    treat them similar to the other shared memory structures.
    
    Since the semaphores are used only in PGPROC array, it makes more sense
    to estimate size of memory required by semaphores to go along with the
    estimation of memory required for that array in ProcGlobalShmemSize().
    Similarly, it makes sense to have the actual shared memory allocations
    for both to be collocated in InitProcGlobal().
    
    With that change CalculateShmemSize() does not need to know about the
    number of semaphores to be allocated, eliminating other asymmetry.
    InitializeShmemGUCs() which used to get the number of semaphores through
    CalculateShmemSize() now fetches that value separately.
    
    Author: Ashutosh Bapat <[email protected]>
    Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
    ashutosh-bapat authored and Commitfest Bot committed Aug 31, 2025
    Configuration menu
    Copy the full SHA
    38c3254 View commit details
    Browse the repository at this point in the history
  3. [CF 5997] Treat semaphores similar to other shared memory structures

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/5997
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CAExHW5uD95UnKdk4Y2rq-yELK6VMXN1bGfrr9o58=BBower3yg@mail.gmail.com
    Author(s): Ashutosh Bapat
    Commitfest Bot committed Aug 31, 2025
    Configuration menu
    Copy the full SHA
    00acb0c View commit details
    Browse the repository at this point in the history
Loading