PostgreSQL adds a queryable log of logical replication conflicts
Apply conflicts that used to vanish into server logs can now be recorded in a system-managed table tied to each subscription.
PostgreSQL will let administrators query a history of logical replication conflicts instead of reconstructing them from server log lines. Amit Kapila committed the change on the PostgreSQL development list after months of review, with Zhijie Hou of Fujitsu driving the patch.
When a subscriber applies changes from a publisher, rows can already be gone, already changed, or otherwise fail to match. In cases such as an update of a deleted row or a delete of a missing row, local data can diverge or be overwritten while the apply worker previously did little more than emit a log message. The new conflict log is meant to give database administrators a durable, queryable record of why a row changed or was skipped.
Each subscription can keep that history in a system-managed table. Recorded replica-identity keys are stored as JSON text that, for most columns, matches what a SELECT of the column would show. Oversized values are omitted rather than truncated, so a shortened key cannot be mistaken for the real one and produce wrong answers when joined or compared against the table. The table is created in the database's default tablespace and deliberately ignores the session setting default_tablespace, so placement stays tied to the subscription rather than to whoever happened to create it. Kapila also noted a privilege mismatch: the usual tablespace check would test the current user, while the table is owned by the subscription owner.
Reviewers, including Robert Haas, spent much of the series on whether a parallel apply worker can safely open a fresh transaction after an error, write the conflict row, and only then rethrow. Kapila argued the pattern matches existing apply-worker recovery and that the leader keeps the worker alive long enough to finish the insert.
Follow-up fixes were already in flight the day of the commit. Hou flagged a drop-order problem that can bypass an existing two-phase-commit deadlock guard, and an error from altering a subscription's conflict-log destination that wrongly reads as if the subscription itself were being dropped.