From d230616135c4d6313d3e9bd72d5d3cd2b5362433 Mon Sep 17 00:00:00 2001 From: Dilip Kumar Date: Sun, 21 Dec 2025 18:51:57 +0530 Subject: [PATCH v15 3/6] Doccumentation patch --- doc/src/sgml/logical-replication.sgml | 122 +++++++++++++++++++++- doc/src/sgml/ref/alter_subscription.sgml | 12 ++- doc/src/sgml/ref/create_subscription.sgml | 36 +++++++ 3 files changed, 164 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index b3faaa675ef..5544f9beb02 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -253,7 +253,11 @@ The subscription is added using CREATE SUBSCRIPTION and can be stopped/resumed at any time using the ALTER SUBSCRIPTION command and removed using - DROP SUBSCRIPTION. + DROP SUBSCRIPTION. When the + conflict_log_destination parameter is set to table + or all, the system automatically manages a dedicated conflict + storage table. This table is dropped automatically when the subscription is + removed via DROP SUBSCRIPTION. @@ -289,6 +293,16 @@ option of CREATE SUBSCRIPTION for details. + + Conflicts that occur during replication are typically logged as plain text + in the server log, which can be difficult for automated monitoring and + analysis. The CREATE SUBSCRIPTION command provides the + + conflict_log_destination option to record detailed + conflict information in a structured, queryable format, significantly + improving post-mortem analysis and operational visibility of the replication + setup by logging to a system-managed table. + Logical Replication Slot Management @@ -2006,9 +2020,14 @@ 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, detailed conflict information is also inserted + into an internally managed table named conflict_log_table_, + providing a structured record of all conflicts. insert_exists @@ -2117,6 +2136,92 @@ Publications: log. + + When the conflict_log_destination is set to + table, the system automatically creates a new table with + a predefined schema to log conflict details. This table is created in the + owner's schema, is owned by the subscription owner, and logs system fields. + The schema of this table is detailed in + . + + + + Conflict Log History 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. + + The log format for logical replication conflicts is as follows: @@ -2412,6 +2517,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..2f3bb0618f5 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,13 @@ ALTER SUBSCRIPTION name RENAME TO < pg_conflict_detection, created to retain dead tuples for conflict detection, will be dropped. + + + When switching conflict_log_destination to table, + the system will ensure the internal logging table exists. If switching away + from table, the logging stops, but the previously recorded + data remains until the subscription is dropped. + diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index 197be0c6f6b..3fa891bc4ae 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_<subid> in the subscription owner's schema. + 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