From b1f2be1ef91231ba6ee4429ca73fbd666dcbcfc6 Mon Sep 17 00:00:00 2001 From: Dilip Kumar Date: Sun, 21 Dec 2025 18:51:57 +0530 Subject: [PATCH v19 3/6] Doccumentation patch --- doc/src/sgml/logical-replication.sgml | 124 +++++++++++++++++++++- doc/src/sgml/ref/alter_subscription.sgml | 14 ++- doc/src/sgml/ref/create_subscription.sgml | 36 +++++++ 3 files changed, 168 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 58ce75d8b63..a2c66b164a0 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -289,6 +289,18 @@ option of CREATE SUBSCRIPTION for details. + + Conflicts that occur during replication are, by default, logged as plain text + in the server log, which can make automated monitoring and analysis difficult. + The CREATE SUBSCRIPTION command provides the + + conflict_log_destination option to record detailed + conflict information in a structured, queryable format. When this parameter + is set to table or all, the system + automatically manages a dedicated conflict storage table, which is created + and dropped along with the subscription. This significantly improves post-mortem + analysis and operational visibility of the replication setup. + Logical Replication Slot Management @@ -2006,9 +2018,15 @@ Publications: - Additional logging is triggered, and the conflict statistics are collected (displayed in the - pg_stat_subscription_stats view) - in the following conflict cases: + Additional logging is triggered, and the conflict statistics are collected + (displayed in the + pg_stat_subscription_stats view) + in the following conflict cases. If the subscription + was created with the conflict_log_destination set to + table or all, detailed conflict + information is inserted into an internally managed table named + pg_conflict.pg_conflict_subscription_oid + , providing a structured record of all conflicts. insert_exists @@ -2118,7 +2136,96 @@ Publications: - The log format for logical replication conflicts is as follows: + When the conflict_log_destination is set to + table or all, the system automatically + creates a new table with a predefined schema to log conflict details. This + table is created in the dedicated pg_conflict namespace. + The schema of this table is detailed in + . + + + + Conflict Log Table Schema + + + + Column + Type + Description + + + + + relid + oid + The OID of the local table where the conflict occurred. + + + schemaname + text + The schema name of the conflicting table. + + + relname + text + The name of the conflicting table. + + + conflict_type + text + The type of conflict that occurred (e.g., insert_exists). + + + remote_xid + xid + The remote transaction ID that caused the conflict. + + + remote_commit_lsn + pg_lsn + The final LSN of the remote transaction. + + + remote_commit_ts + timestamptz + The remote commit timestamp of the remote transaction. + + + remote_origin + text + The origin of the remote transaction. + + + remote_tuple + json + The JSON representation of the incoming remote row that caused the conflict. + + + local_conflicts + json[] + + An array of JSON objects representing the local state for each conflict attempt. + Each object includes the local transaction ID (xid), commit + timestamp (commit_ts), origin (origin), + conflicting key data (key), and the full local row + image (tuple). + + + + +
+ + + The conflicting row data, including the original local tuple and + the remote tuple, is stored in JSON columns (local_tuple + and remote_tuple) for flexible querying and analysis. + + + + If conflict_log_destination is left at the default + setting or explicitly configured as log or + all, logical replication conflicts are logged in the + following format: LOG: conflict detected on relation "schemaname.tablename": conflict=conflict_type DETAIL: detailed_explanation. @@ -2412,6 +2519,15 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER key or replica identity defined for it. + + + + The internal table automatically created when conflict_log_destination + is set to table or all is excluded from + logical replication. It will not be published, even if a publication on the + subscriber is defined using FOR ALL TABLES. + + diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml index 27c06439f4f..90331f590e0 100644 --- a/doc/src/sgml/ref/alter_subscription.sgml +++ b/doc/src/sgml/ref/alter_subscription.sgml @@ -280,8 +280,9 @@ ALTER SUBSCRIPTION name RENAME TO < origin, failover, two_phase, - retain_dead_tuples, and - max_retention_duration. + retain_dead_tuples, + max_retention_duration and, + conflict_log_destination. Only a superuser can set password_required = false. @@ -339,6 +340,15 @@ ALTER SUBSCRIPTION name RENAME TO < pg_conflict_detection, created to retain dead tuples for conflict detection, will be dropped. + + + When the conflict_log_destination parameter is set to + table or all, the system + automatically creates the internal logging table if it does not already + exist. Conversely, if the destination is changed to + log, logging to the table stops and the internal + table is automatically dropped. + diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index b7dd361294b..f50bdb52f35 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -274,6 +274,42 @@ CREATE SUBSCRIPTION subscription_name + + conflict_log_destination (enum) + + + Specifies the destination for recording logical replication conflicts. + The supported values are log, table, + and all. The default is log. + + + The available destinations are: + + + + log: Conflict details are recorded in the server log. + This is the default behavior. + + + + + table: The system automatically creates a structured table + named pg_conflict.conflict_log_table_<subid>. + This allows for easy querying and analysis of conflicts. This table is + automatically dropped when the subscription is removed. + + + + + all: Records the conflict information to both the server log + and the dedicated conflict table. + + + + + + + streaming (enum) -- 2.43.0