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

Commits on Dec 25, 2025

  1. Add configurable conflict log table for Logical Replication

    This patch adds a feature to provide a structured, queryable record of all
    logical replication conflicts. The current approach of logging conflicts as
    plain text in the server logs makes it difficult to query, analyze, and
    use for external monitoring and automation.
    
    This patch addresses these limitations by introducing a configurable
    conflict_log_destination=('log'/'table'/'all') option in the CREATE SUBSCRIPTION
    command.
    
    If the user chooses to enable logging to a table (by selecting 'table' or 'all'),
    an internal logging table named conflict_log_table_<subid> is automatically
    created within a dedicated, system-managed namespace named pg_conflict. This table
    is linked to the subscription via an internal dependency, ensuring it is
    automatically dropped when the subscription is removed.
    
    The conflict details, including the original and remote tuples, are stored in JSON
    columns, providing a flexible format to accommodate different table schemas.
    
    The log table captures essential attributes such as local and remote transaction IDs,
    LSNs, commit timestamps, and conflict type, providing a complete record for post-mortem
    analysis.
    
    This feature will make logical replication conflicts easier to monitor and manage,
    significantly improving the overall resilience and operability of replication setups.
    
    The conflict log tables will not be included in a publication, even if the publication
    is configured to include ALL TABLES or ALL TABLES IN SCHEMA.
    Dilip Kumar authored and Commitfest Bot committed Dec 25, 2025
    Configuration menu
    Copy the full SHA
    a381b41 View commit details
    Browse the repository at this point in the history
  2. Implement the conflict insertion infrastructure for the conflict log …

    …table
    
    This patch introduces the core logic to populate the conflict log table whenever
    a logical replication conflict is detected. It captures the remote transaction
    details along with the corresponding local state at the time of the conflict.
    
    Handling Multi-row Conflicts: A single remote tuple may conflict with multiple
    local tuples (e.g., in the case of multiple_unique_conflicts). To handle this,
    the infrastructure creates a single row in the conflict log table for each
    remote tuple. The details of all conflicting local rows are aggregated into a
    single JSON array in the local_conflicts column.
    
    The JSON array uses the following structured format:
    [ { "xid": "1001", "commit_ts": "2025-12-25 10:00:00+05:30", "origin": "node_1",
    "key": {"id": 1}, "tuple": {"id": 1, "val": "old_data"} }, ... ]
    
    Example of querying the structured conflict data:
    
    SELECT remote_xid, relname, remote_origin, local_conflicts[1] ->> 'xid' AS local_xid,
           local_conflicts[1] ->> 'tuple' AS local_tuple
    FROM myschema.conflict_log_history2;
    
     remote_xid | relname  | remote_origin | local_xid |     local_tuple
    ------------+----------+---------------+-----------+---------------------
            760 | test     | pg_16406      | 771       | {"a":1,"b":10}
            765 | conf_tab | pg_16406      | 775       | {"a":2,"b":2,"c":2}
    Dilip Kumar authored and Commitfest Bot committed Dec 25, 2025
    Configuration menu
    Copy the full SHA
    2059bb9 View commit details
    Browse the repository at this point in the history
  3. Doccumentation patch

    Dilip Kumar authored and Commitfest Bot committed Dec 25, 2025
    Configuration menu
    Copy the full SHA
    7d119b4 View commit details
    Browse the repository at this point in the history
  4. [CF 6252] v16 - Proposal: Conflict log history table for Logical Repl…

    …ication
    
    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/6252
    
    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/CAFiTN-u+_mFj9caYYFO7=_YHFXk5y=vvOm2H2=5hctYktmAVGA@mail.gmail.com
    Author(s): Dilip Kumar
    Commitfest Bot committed Dec 25, 2025
    Configuration menu
    Copy the full SHA
    fbb915b View commit details
    Browse the repository at this point in the history
Loading