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

Commits on Apr 8, 2025

  1. Fix data loss in logical replication

    Previously, logical replication could lose data if one user modified a
    publication to add a table while another user concurrently modified that table
    and commit later than the publication modification transaction. The issue
    arised during the decoding of transactions modifying the table: if the initial
    catalog cache was built using a snapshot taken before the publication DDL
    execution, all subsequent changes to that table were decoded with outdated
    catalog cache, which caused them to be filtered from replication. This happened
    because invalidation messages were only present in the publication modification
    transaction, which was decoded before these subsequent changes.
    
    This issue is not limited to publication DDLs; similar problems can occur with
    ALTER TYPE statements executed concurrently with DMLs, leading to incorrect
    decoding under outdated type contexts.
    
    To address this, the commit improves logical decoding by ensuring that
    invalidation messages from catalog-modifying transactions are distributed to
    all concurrent in-progress transactions. This allows the necessary rebuild of
    the catalog cache when decoding new changes, similar to handling historic
    catalog snapshots (see SnapBuildDistributeNewCatalogSnapshot()).
    
    Following this change, some performance regression is observed, primarily
    during frequent execution of publication DDL statements that modify published
    tables. This is an expected trade-off due to cache rebuild and distribution
    overhead. The regression is minor or nearly nonexistent when DDLs do not affect
    published tables or occur infrequently, making this a worthwhile cost to
    resolve a longstanding data loss issue.
    
    An alternative approach considered was to take a strong lock on each affected
    table during publication modification. However, this would only address issues
    related to publication DDLs and require locking every relation in the database
    for publications created as FOR ALL TABLES, which is impractical. Thus, this
    commit chooses to distribute invalidation messages as outlined above.
    skkyal authored and Commitfest Bot committed Apr 8, 2025
    Configuration menu
    Copy the full SHA
    3723471 View commit details
    Browse the repository at this point in the history
  2. [CF 4766] v20 - data loss bug in initial sync of logical replication

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/4766
    
    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/OSCPR01MB14966DDB92FA7DA8FA8658216F5DE2@OSCPR01MB14966.jpnprd01.prod.outlook.com
    Author(s): Tomas Vondra
    Commitfest Bot committed Apr 8, 2025
    Configuration menu
    Copy the full SHA
    7b3d427 View commit details
    Browse the repository at this point in the history
Loading