diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index f82adfc..2077c6a 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -1568,7 +1568,7 @@ test_sub=# SELECT * FROM t1 ORDER BY id; - Conflicts and conflict resolution + Conflicts and Conflict Resolution Logical replication behaves similarly to normal DML operations in that @@ -1582,18 +1582,19 @@ test_sub=# SELECT * FROM t1 ORDER BY id; - Additional logging is triggered in various conflict scenarios, each identified as a - conflict type, and the conflict statistics are collected (displayed in the - pg_stat_subscription_stats view). - Users have the option to configure a conflict_resolver for each - conflict_type when creating a subscription. - For more information on the supported conflict_types detected and - conflict_resolvers, refer to section - CONFLICT RESOLVERS. - - Note that there are other conflict scenarios, such as exclusion constraint - violations. Currently, we do not provide additional details for them in the - log. + There are various conflict scenarios, each identified as a conflict type. + Users can configure a conflict resolver for each + conflict type when creating a subscription. For more information, refer to + + CREATE SUBSCRIPTION ... CONFLICT RESOLVER. + + + When a conflict occurs the details about it are logged, and the conflict + statistics are recorded in the + pg_stat_subscription_stats view. + Note that there are other conflict scenarios, such as exclusion constraint + violations. Currently, we do not provide additional details for them in the + log. diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml index 55eae8b..1982130 100755 --- a/doc/src/sgml/ref/alter_subscription.sgml +++ b/doc/src/sgml/ref/alter_subscription.sgml @@ -353,22 +353,32 @@ ALTER SUBSCRIPTION name RESET CONFL CONFLICT RESOLVER ( conflict_type [= conflict_resolver] [, ... ] ) - This clause alters either the default conflict resolvers or those set by . - Refer to section CONFLICT RESOLVERS - for the details on supported conflict_types and conflict_resolvers. + This clause alters the current conflict resolver for the specified conflict types. + Refer to + CREATE SUBSCRIBER ... CONFLICT RESOLVER + for details about different conflict_type and what + kind of conflict_resolver can be assigned to them. + + + conflict_type + + + The conflict type. + + + + + conflict_resolver + + + The conflict resolver to use for this conflict type. + + + + - - - conflict_type - - - The conflict type being reset to its default resolver setting. - For details on conflict types and their default resolvers, refer to section CONFLICT RESOLVERS - - - diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index 25d4c0b..e3d435a 100755 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -98,6 +98,202 @@ CREATE SUBSCRIPTION subscription_name + + CONFLICT RESOLVER ( conflict_type = conflict_resolver [, ... ] ) + + + This optional clause specifies conflict resolvers for different conflict_types. + + + + The default behavior for each conflict_type is listed below. + + + insert_exists (enum) + + + This conflict occurs when inserting a row that violates a + NOT DEFERRABLE unique constraint. + To log the origin and commit timestamp details of the conflicting key, + track_commit_timestamp + should be enabled on the subscriber. In this case, an error will be + raised until the conflict is resolved manually or the resolver is configured to a + non-default value that can automatically resolve the conflict. + + + + + + update_exists (enum) + + + This conflict occurs when the updated value of a row violates + a NOT DEFERRABLE + unique constraint. To log the origin and commit + timestamp details of the conflicting key, + track_commit_timestamp + should be enabled on the subscriber. In this case, an error will be + raised until the conflict is resolved manually or the resolver is configured to a + non-default value that can automatically resolve the conflict. + Note that when updating a partitioned table, if the updated row + value satisfies another partition constraint resulting in the + row being inserted into a new partition, the insert_exists + conflict may arise if the new row violates a NOT DEFERRABLE + unique constraint. + + + + + + update_missing (enum) + + + This conflict occurs when the tuple to be updated was not found. + The update will simply be skipped in this scenario. + + + + + + update_origin_differs (enum) + + + This conflict occurs when updating a row that was previously + modified by another origin. + Note that this conflict can only be detected when + track_commit_timestamp + is enabled on the subscriber. Currently, the update is always applied + regardless of the origin of the local row. + + + + + + delete_missing (enum) + + + This conflict occurs when the tuple to be deleted was not found. + The delete will simply be skipped in this scenario. + + + + + + delete_origin_differs (enum) + + + This conflict occurs when deleting a row that was previously modified + by another origin. Note that this conflict can only be detected when + track_commit_timestamp + is enabled on the subscriber. Currently, the delete is always applied + regardless of the origin of the local row. + + + + + + + + + The behavior of each conflict_resolver + is described below. Users can choose from the following resolvers for automatic conflict + resolution. + + + + apply_or_error (enum) + + + This resolver is only used for update_missing. + An attempt is made to convert the update into an insert; if this cannot + be done due to missing information, then an error is thrown, and replication + is stopped. + + + + + + apply_or_skip (enum) + + + This resolver is only used for update_missing. + An attempt is made to convert the update into an insert; if this + cannot be done due to missing information, then the change is skipped. + + + + + + apply_remote (enum) + + + This resolver applies the remote change. It can be used for + insert_exists, update_exists, + update_origin_differs and delete_origin_differs. + It is the default resolver for insert_exists and + update_exists. + + + + + + error (enum) + + + This resolver throws an error and stops replication. It can be used for + any conflict type. + It is the default resolver for insert_exists and + update_exists. + + + + + + keep_local (enum) + + + With this resolver, the remote change is not applied and the local tuple is maintained. + It can be used for insert_exists, update_exists, + update_origin_differs and delete_origin_differs. + + + + + + skip (enum) + + + This resolver skips processing the remote change and continue replication + with the next change. + It can be used for update_missing and + delete_missing and is the default resolver for these types. + + + + + + + + + Conflict type/resolver Summary + + + Conflict type Default resolver Possible resolvers + + + insert_exists error apply_remote, error, keep_local + update_exists error apply_remote, error, keep_local + update_missing skip apply_or_error, apply_or_skip, error, skip + update_origin_differsapply_remote apply_remote, error, keep_local + delete_missing skip error, skip + delete_origin_differsapply_remote apply_remote, error, keep_local + + +
+ +
+
+ WITH ( subscription_parameter [= value] [, ... ] ) @@ -433,183 +629,6 @@ CREATE SUBSCRIPTION subscription_name - - - CONFLICT RESOLVER ( conflict_type = conflict_resolver [, ... ] ) - - - This optional clause specifies options for conflict resolvers for different conflict_types. - - - - The conflict_type and their default behaviour are listed below. - - - insert_exists (enum) - - - This conflict occurs when inserting a row that violates a - NOT DEFERRABLE unique constraint. - To log the origin and commit timestamp details of the conflicting key, - track_commit_timestamp - should be enabled on the subscriber. In this case, an error will be - raised until the conflict is resolved manually or the resolver is configured to a - non-default value that can automatically resolve the conflict. - - - - - - update_origin_differs (enum) - - - This conflict occurs when updating a row that was previously - modified by another origin. - Note that this conflict can only be detected when - track_commit_timestamp - is enabled on the subscriber. Currently, the update is always applied - regardless of the origin of the local row. - - - - - - update_exists (enum) - - - This conflict occurs when the updated value of a row violates - a NOT DEFERRABLE - unique constraint. To log the origin and commit - timestamp details of the conflicting key, - track_commit_timestamp - should be enabled on the subscriber. In this case, an error will be - raised until the conflict is resolved manually or the resolver is configured to a - non-default value that can automatically resolve the conflict. - Note that when updating a partitioned table, if the updated row - value satisfies another partition constraint resulting in the - row being inserted into a new partition, the insert_exists - conflict may arise if the new row violates a NOT DEFERRABLE - unique constraint. - - - - - - update_missing (enum) - - - This conflict occurs when the tuple to be updated was not found. - The update will simply be skipped in this scenario. - - - - - - delete_origin_differs (enum) - - - This conflict occurs when deleting a row that was previously modified - by another origin. Note that this conflict can only be detected when - track_commit_timestamp - is enabled on the subscriber. Currently, the delete is always applied - regardless of the origin of the local row. - - - - - - delete_missing (enum) - - - This conflict occurs when the tuple to be deleted was not found. - The delete will simply be skipped in this scenario. - - - - - - - - The conflict_resolver and their behaviour - are listed below. Users can use any of the following resolvers for automatic conflict - resolution. - - - - error (enum) - - - This resolver throws an error and stops replication. It can be used for - any conflict type. - It is the default resolver for insert_exists and - update_exists. - - - - - - skip (enum) - - - This resolver skips processing the remote change and continue replication - with the next change. - It can be used for update_missing and - delete_missing and is the default resolver for these types. - - - - - - apply_remote (enum) - - - This resolver applies the remote change. It can be used for - insert_exists, update_exists, - update_origin_differs and delete_origin_differs. - - It is the default resolver for insert_exists and - update_exists. - - - - - - keep_local (enum) - - - With this resolver, the remote change is not applied and the local tuple is maintained. - It can be used for insert_exists, update_exists, - update_origin_differs and delete_origin_differs. - - - - - - apply_or_skip (enum) - - - This resolver is only used for update_missing. - An attempt is made to convert the update into an insert; if this - cannot be done due to missing information, then the change is skipped. - - - - - - apply_or_error (enum) - - - This resolver is only used for update_missing. - An attempt is made to convert the update into an insert; if this cannot - be done due to missing information, then an error is thrown, and replication - is stopped. - - - - - - -