Conflicts v5
Conflict detection
List of conflict types
PGD recognizes the following conflict types, which can be used as the conflict_type
parameter:
insert_exists
— An incoming insert conflicts with an existing row by way of a primary key or a unique key/index.update_differing
— An incoming update's key row differs from a local row. This can happen only when using row version conflict detection.update_origin_change
— An incoming update is modifying a row that was last changed by a different node.update_missing
— An incoming update is trying to modify a row that doesn't exist.update_recently_deleted
— An incoming update is trying to modify a row that was recently deleted.update_pkey_exists
— An incoming update has modified thePRIMARY KEY
to a value that already exists on the node that's applying the change.multiple_unique_conflicts
— The incoming row conflicts with multiple UNIQUE constraints/indexes in the target table.delete_recently_updated
— An incoming delete with an older commit timestamp than the most recent update of the row on the current node or when using row version conflict detection.delete_missing
— An incoming delete is trying to remove a row that doesn't exist.target_column_missing
— The target table is missing one or more columns present in the incoming row.source_column_missing
— The incoming row is missing one or more columns that are present in the target table.target_table_missing
— The target table is missing.apply_error_ddl
— An error was thrown by Postgres when applying a replicated DDL command.
Conflict resolution
Most conflicts can be resolved automatically. PGD defaults to a last-update-wins mechanism or, more accurately, the update_if_newer
conflict resolver. This mechanism retains the most recently inserted or changed row of the two conflicting ones based on the same commit timestamps used for conflict detection. The behavior in certain corner-case scenarios depends on the settings used for bdr.create_node_group
and alternatively for bdr.alter_node_group
.
PGD lets you override the default behavior of conflict resolution by using the following function.
List of conflict resolvers
Several conflict resolvers are available in PGD, with differing coverages of the conflict types they can handle:
error