Bidirectional Snapshot Replicaton Setup
RE-SB-2 Publishing a table
Defining conflict resolvers
Preliminaries
Because every table can have only one publisher conflicts can occur only on publisher (when modifications from subscriber are applied).
Every table on publisher can have a number of conflict resolvers which are used for conflict resolution. Each conflict resolver has a type ('I', 'U', or 'D') and an order. Conflict resolvers are applied in ascending order.
Conflict resolver is a Virtuoso/PL procedure which receives conflicting row (row from subscriber) and some other arguments. Conflict resolver signatures are described in Virtuoso documentation. Conflict resolver can modify the row which is passed in as 'inout' arguments. Conflict resolver should return an integer value which will be used for conflict resolution. Possible return values and their meaning are described in Virtuoso documentation.
Conflict resolution occurs differently for each kind of DML operation. Details can be found in Virtuoso documentation.
There is a possibility to automatically generate some types of conflict resolvers. Automatically generated conflict resolver classes are:
- max - row with maximum value of specified column wins
- min - row with minumum value of specified column wins
- ave - new value of specified column is calculated as: current_val = (current_val + new_val) / 2
- pub_wins - publisher always wins
- sub_wins - subscriber always wins
Example defining a conflict resolver
- Login to the Conductor UI using the dba account.
- Go to the "Replication" tab and then go to the "Bidirectional Snapshot" tab.
- Click "Conflict Resolvers" for the desired published table ("Demo.demo.Orders").
- Press "New Resolver" button.
- Enter conflict resolver name suffix (enter "max_OrderDate"), select conflict resolver type (select "U"), select conflict resolver class (select "max"), select a column (select "OrderDate"). You can optionally specify conflict resolver order (default is 100).
- Press "Add" button. A conflict resolver will be added. You can view and edit conflict resolver code by selecting a link with its name from the list of conflict resolvers.
Equivalent SQL commands to above
- Connect to the Virtuoso server via ISQL utility as DBA user.
- Create 'U' conflict resolver for table "Demo.demo.Orders"
that will choose a row with latest OrderDate.
SQL> REPL_ADD_SNAPSHOT_CR ('Demo.demo.Orders', 'max_OrderDate', 'U', 100, 'max', 'OrderDate');
| View the source | Action |
|---|---|
| 1. re_sb_2.sql | Set the initial state |
OpenLink Home
Technical Support