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: postgres/postgres-cfbot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/6401~1
Choose a base ref
...
head repository: postgres/postgres-cfbot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/6401
Choose a head ref
  • 8 commits
  • 57 files changed
  • 2 contributors

Commits on Oct 25, 2026

  1. Add stress tests for concurrent index builds

    Exercise CREATE INDEX CONCURRENTLY and REINDEX CONCURRENTLY while other
    sessions insert and update rows. Cover all built-in index types, unique
    indexes, expressions, predicates, parallel builds, and both READ COMMITTED
    and REPEATABLE READ.
    
    Include HOT updates, out-of-line TOAST values with concurrent vacuuming,
    and an opclass whose support function executes SQL. Check the resulting
    indexes with amcheck or by comparing index and sequential scans under the
    same snapshot.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    16e1011 View commit details
    Browse the repository at this point in the history
  2. Periodically reset snapshots in concurrent index builds

    Long-running concurrent index builds hold back vacuum by pinning xmin.
    Replace the snapshot periodically during the first heap scan so the
    horizon can advance. The earlier attempt to let vacuum ignore these
    snapshots (d9d0762, reverted by e28bb88) was unsafe because HOT pruning
    could cause the build to miss tuples.
    
    Add the SO_RESET_SNAPSHOT scan option and let index access methods opt in
    with amcanresetsnapshot. RotateSnapshot() replaces the active snapshot
    and releases the catalog snapshot while keeping xmin valid throughout.
    
    Reset at page boundaries after concurrent_index_reset_snapshot_interval
    milliseconds; 0 resets on every page and -1 disables resets. Skip resets
    at REPEATABLE READ or above, where the transaction snapshot pins xmin
    anyway.
    
    For now, enable this only for serial, non-unique builds, excluding GIN and
    BRIN. Later commits add those cases. The validation scan still needs a
    single snapshot.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    c93b72a View commit details
    Browse the repository at this point in the history
  3. Allow snapshot resets in concurrent GIN builds

    GIN's build accumulator keeps keys across heap pages. If a key is stored
    out of line, copying it only copies the TOAST pointer. After a snapshot
    reset, vacuum could remove the referenced data before GIN writes the key
    to the index.
    
    Fetch external values when copying them into the accumulator, while the
    scan snapshot still protects them, and enable amcanresetsnapshot. Built-in
    opclasses already return keys without external TOAST pointers; this also
    makes resets safe for other opclasses.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    ddba671 View commit details
    Browse the repository at this point in the history
  4. Allow snapshot resets in concurrent BRIN builds

    BRIN keeps values in a range summary until the range is written out.
    For out-of-line values, those copies are only TOAST pointers. Resetting
    the snapshot can let vacuum or pruning remove the data before the next
    comparison, causing the build to fail.
    
    Fetch external values before adding them to the summary, and enable
    amcanresetsnapshot. Do this for all BRIN builds. Allocate retained values
    in the range's memory context so they are freed when the range is done.
    This also prevents minmax_multi from serializing TOAST pointers during a
    build; the insert path is unchanged.
    
    Add a test that deletes a summarized row between snapshot resets and
    checks that the build can still read the retained value.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    dd7c3f0 View commit details
    Browse the repository at this point in the history
  5. Allow snapshot resets in parallel concurrent index builds

    The leader must keep its initial snapshot until every worker has restored
    it. Have workers signal through the shared scan descriptor when they
    have joined the scan with their own snapshot. The leader waits for those
    signals before it starts scanning and can release the original snapshot.
    Each participant then replaces its snapshot independently.
    
    Use the build's active snapshot as the initial scan snapshot, avoiding a
    separately registered snapshot that would keep xmin pinned. This enables
    resets for parallel GIN, BRIN, and non-unique btree builds. Worker
    attachment now happens before the leader joins the scan in all parallel
    builds.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    c489d8e View commit details
    Browse the repository at this point in the history
  6. Allow snapshot resets in concurrent unique index builds

    With snapshot resets, equal keys collected by the scan may belong to rows
    that were never live at the same time. Check their current heap status
    in _bt_load() before reporting a uniqueness violation.
    
    Limit heap fetches in tuplesort and _bt_load() using separate budgets,
    controlled by index_build_duplicate_check_scale_factor (5% by default).
    Each budget allows at least 1000 fetches unless the setting is zero.
    Leave unchecked equal-key entries out of the index so validation can
    insert them with a full uniqueness check.
    
    Also leave entries for validation when a possible conflict involves an
    unfinished delete or update. Validation runs after waiting for older
    writers, so a concurrent delete can resolve the apparent duplicate.
    
    Concurrent unique builds no longer need a separate spool for dead tuples,
    since the MVCC scan only supplies tuples visible to its current snapshot.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    99d55af View commit details
    Browse the repository at this point in the history
  7. Reset snapshots after the heap scan in concurrent index builds

    After the heap scan, merging and writing index tuples can still take a
    long time while holding the scan's last snapshot and pinning xmin.
    
    Add index_build_rotate_snapshot() and call it between tuples in the
    remaining btree, hash, GIN, BRIN, and GiST build loops. Use the same reset
    interval as the scan and keep an active snapshot available for support
    functions that execute SQL and heap lookups that need xmin protection.
    
    Sorting and intermediate merges inside tuplesort still hold one snapshot
    for their duration. The validation phase also keeps its fixed snapshot.
    
    Test resets after the scan, including buffered GiST builds and opclasses
    whose support functions execute SQL in serial and parallel builds.
    
    Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
    michail-nikolaev authored and Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    a498605 View commit details
    Browse the repository at this point in the history
  8. [CF 6401] v8 - Resetting snapshots during the first phase of [CREATE …

    …|RE]INDEX CONCURRENTLY
    
    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/6401
    
    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/CADzfLwV+ng11CQPju9HxJvK_rLAZ0_Zozno_+4Td26ZL1V_=rA@mail.gmail.com
    Author(s): Mihail Nikalayeu
    Commitfest Bot
    Commitfest Bot committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    e3746af View commit details
    Browse the repository at this point in the history
Loading