From 609b6825ec8a90b7ad66bbec5831f809103c7a2f Mon Sep 17 00:00:00 2001 From: Dilip Kumar Date: Sun, 21 Dec 2025 18:51:57 +0530 Subject: [PATCH v20 3/3] Doccumentation patch --- doc/src/sgml/logical-replication.sgml | 116 +++++++++++++++++++++- doc/src/sgml/ref/alter_subscription.sgml | 14 ++- doc/src/sgml/ref/create_subscription.sgml | 34 +++++++ 3 files changed, 161 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 68d6efe5114..41517bf2716 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -289,6 +289,19 @@ 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 log 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 @@ -2118,7 +2131,98 @@ 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 name of the conflict log table + is pg_conflict_subscription_oid. 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 +2516,16 @@ 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..2de2c3c52fb 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 conflict log 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..05e4a700eff 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -247,6 +247,40 @@ CREATE SUBSCRIPTION subscription_name + + conflict_log_destination (enum) + + + Specifies the destination for recording logical replication conflicts. + + + 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_<subid> in the + pg_conflict schema. This allows for easy querying and + analysis of conflicts. This table is automatically dropped when the + subscription is removed. + + + + + all: Records to both the server log and the table. + + + + + + + copy_data (boolean) -- 2.49.0