Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

WIth 2-way replication there is more chance of getting conflicts than with 1-way replication. This is because both sides are being updated in real time. 

...

We have the following table with the same data in both databases:

Section
Column
width5%

 

Column
width95
Panel No Format
bgColorCCC
Table TOLL.TOLL_ZONE


Id  Name      Update_date


--  --------  -----------------

1   Lane

1   Lane 1    10/10/2012 23:00

2   Lane

2   Lane 2    09/10/2012 21:00

 

Now the following scenario happens:

1. 2-Way replication is configured between table TOLL_ZONE in Database A and Database B
2. Both tables are in sync
3. Communication between database A and database B breaks and Dbvisit Replicate is no longer able to replicate changes
4. Record with id=2 is updated on database A and database B with different values:

 

Section
Column
width5%

 

Column
width95
Panel No Format
bgColorCCC
DATABASE A


Table TOLL.TOLL_ZONE


Id  Name      Update_date


--  --------  -----------------

1   Lane

1   Lane 1    10/10/2012 23:00

2   Lane

2   Lane 222  12/12/2012 09:45  <== Updated



DATABASE B


Table TOLL.TOLL_ZONE


Id  Name      Update_date


--  --------  -----------------

1   Lane

1   Lane 1    10/10/2012 23:00

2   Lane

2   Lane 200  12/12/2012 10:10  <== Updated latest

 

5. Communication is restored
6. What will happen to the replication now that there are 2 different values in each database?

...

If we assume that the newer or latest value is always the value that we want, then we can set the following conflict handler:

Section
Column
width5%

 

Column
width95
Panel No Format
bgColorCCC
dbvrep> set SET_CONFLICT_HANDLERS for table TOLL.TOLL_ZONE for update on NO_DATA to NEWER by columns UPDATE_DATE

 

This conflict handler:

  • Is set for all update statements run against the TOLL.TOLL_ZONE table
  • Will use the UPDATE_DATE column in the TOLL.TOLL_ZONE table to determine which is the NEWER data
  • Will overwrite the data that is in the TOLL.TOLL_ZONE with the update statement if UPDATE_DATE in the update statement is newer than in the TOLL.TOLL_ZONE table
  • Will ignore the update statement if UPDATE_DATE in the update statement is older than in the TOLL.TOLL_ZONE table

The end result is that both tables will be back in sync with the following data:

Section
Column
width5%

 

Column
width95
Panel No Format
bgColorCCC
DATABASE A


Table TOLL.TOLL_ZONE


Id  Name      Update_date


--  --------  -----------------

1   Lane

1   Lane 1    10/10/2012 23:00
2   Lane

2   Lane 200  12/12/2012 10:10

DATABASE B


Table TOLL.TOLL_ZONE


Id  Name      Update_date


--  --------  -----------------

1   Lane

1   Lane 1    10/10/2012 23:00

2   Lane

2   Lane 200  12/12/2012 10:10

 

To see the existing conflict handlers for a table, please see:

Section
Column
width5%

 

Column
width95
Panel No Format
bgColorCCC
dbvrep> SHOW_CONFLICT_HANDLERS FOR TABLE owner.name: owner.name is name of the table on SOURCE database.

 

CHOOSE REPLICATION

By default all commands in the Dbvisit Replicate console work with the default processes MINE and APPLY. The choose replication command is useful when working with 2-way replication where there are multiple processes such as MINE, APPLY, MINE1 and APPLY1. Note that the

Note

The CHOOSE REPLICATION command selects all processes for the indicated replication (so both Mine and Apply processes).

 

Example:

Panelnoformat
bgColorCCC
dbvrep>dbvrep> CHOOSE REPLICATION MINE1

 The above command will choose the replication pair that is associated with MINE1. Typically this is MINE1->APPLY1. Note that the CHOOSE REPLICATION


Note

The CHOOSE REPLICATION command is needed prior to issuing commands to display, resolve and set conflicts for the APPLY1 process.