Conflict Resolution Algorithms
An asynchronous replication system allowing data updates in more than one site per session, such as in an update anywhere data model, may cause some replication conflict between different users operations.
PgReplicator comes with a set of algorithms that detect potential conflicts, resolve them and rollback all rejected operations.
The conflict resolution module acts as a filter on each auxiliary table containing local and remote users operations, accepting or rejecting them accordingly to the algorithm specified in resolver attribute of pgr_tables.
tablename |
permissions |
... |
resolv_site |
resolver |
... |
table1 |
RWT |
... |
2 |
TS |
... |
table2 |
RWT |
... |
1 |
FTS |
... |
The following table shows how these algorithms work. Operations refer to that generated by users between two synchronization events.
Site-oriented algorithms (1SO, FSO) detects potential conflicts by focusing only the site from which operations were generated. Row-oriented algorithms (FSO, FTO, TS) detects potential conflicts by inspecting the sequence of operations related to each single record (target-record) of the replicated table, permitting to accept, for different records, operations coming from different sites.
Resolver name |
How it works |
NO |
No conflict detection. All operations are accepted by default. |
1SO |
One Site Only. All operations are rejected if they come from more than one site. Only when operations are generated by a single site they are accepted. |
FSO |
First Site Only. Detects conflicts as 1SO do, but accepts operations coming from the site which made the first. |
FTO |
First Transaction Only. For each target-record, the sequence of operations related to it is taken and the first sub-sequence coming from the same site is accepted. |
FTS |
First Transaction Site. For each target-record, the sequence of operations related to it is taken and, amongst these, only those coming from the site which made the first operation are accepted. |
TS |
TimeStamp. For each target-record, the sequence of operations related to it is accepted and, amongst these, only those coming from the site which made the last operation are accepted. |
MP |
Master Priority. Applied after a row-oriented
algorithm ensures that operations generated on the master site
always win. We refers to the master site for a record as the site
on which the record was generated the first time. |
pgReplicator permits you to check how conflict resolution module works. Suppose you have a replicated database test, in which different algorithms are selected for different replicated tables. After capturing operations on the involved sites, you can run pgr as follows:
pgr -resolv test |
stop replica session before updating users' tables, then standby, permitting you to examine auxiliary tables |
pgr -update test |
complete a -resolv replica session |
pgr -rrs test |
rollback a standby replica session |
NEXT SECTION: More on database synchronization process |