Quantcast
Channel: GoldenGate – Oracle DBA – Tips and Techniques
Viewing all articles
Browse latest Browse all 80

GoldenGate Active-Active Replication with Conflict Detection and Resolution (CDR) – Part 3

$
0
0

In the earlier post we saw a case of GoldenGate Conflict Resolution using the Trusted Site Or Trusted Source method where one site is dedicated as the trusted or master site and in a CDR scenario will always prevail over other sites participating in the Active-Active Replication.

We saw how an UPDATE statement conflict was detected and resolved with the trail file send from the trusted site (Site A) overwriting the update made on Site B and on Site A, the trail file which was sent from Site B was ignored.

Let us now look at a CDR situation which is resolved by using the USEMIN clause in the RESOLVECONFLICT parameter.

The USEMIN keyword means that If the value of the conflict resolution column (in this case LAST_DML) recorded in the trail file is less than the value of the column in the database, then apply the update from the trail file, else ignore the update recorded in the trail file

This is how the replicat parameter file will look like on both sites. The same extract and data pump parameter files as deesribed in the earlier posts will be used for this example.

Site A

GGSCI (pdemvrhl061) 3> view params rep1

REPLICAT rep1
ASSUMETARGETDEFS
USERID ggate, PASSWORD ggate
DISCARDFILE /u01/app/ggate/discard.txt, append,
MAP sh.inventory, TARGET sh.inventory,
COMPARECOLS (ON UPDATE ALL, ON DELETE ALL),
RESOLVECONFLICT (UPDATEROWEXISTS,
(DEFAULT, USEMIN (last_dml)));

Site B

GGSCI (pdemvrhl062) 2> view params rep2

REPLICAT rep2
ASSUMETARGETDEFS
USERID ggate, PASSWORD ggate
DISCARDFILE /u01/app/ggate/discard.txt, append,
MAP sh.inventory, TARGET sh.inventory,
COMPARECOLS (ON UPDATE ALL, ON DELETE ALL),
RESOLVECONFLICT (UPDATEROWEXISTS,
(DEFAULT, USEMIN (last_dml)));

On Site A
update inventory
set QTY_IN_STOCK=11 where prod_id=101;

commit;

On Site B
update inventory
set QTY_IN_STOCK=1 where prod_id=101;

commit;

End Result

select * from inventory;

   PROD_ID PROD_CATEGORY        QTY_IN_STOCK LAST_DML
---------- -------------------- ------------ --------------------------------------
       102 Baseball                      105 10-APR-13 04.44.01.500114 PM
       101 Football                        1 11-APR-13 03.28.01.388828 PM

Update performed on Site B has prevailed in this case.

Let us examine the trail files on both sites using logdump utility and see why.

Trail File on Site A (sent from source Site B)

Name: SH.INVENTORY
After  Image:                                             Partition 4   G  e
0000 0007 0000 0003 3130 3100 0200 0500 0000 0131 | ........101........1 
 0003 001f 0000 3230 3133 2d30 342d 3131 3a31 353a | ......2013-04-11:15: 
 3238 3a30 312e 3338 3838 3238 3030 30             | 28:01.388828000

Trail File on Site B (sent from source Site A)

2013/04/11 15:28:01.959.870 FieldComp            Len    56 RBA 3461
Name: SH.INVENTORY
After  Image:                                             Partition 4   G  e
0000 0007 0000 0003 3130 3100 0200 0600 0000 0231 | ........101........1
3100 0300 1f00 0032 3031 332d 3034 2d31 313a 3135 | 1......2013-04-11:15
3a32 383a 3032 2e30 3537 3238 3030 3030           | :28:02.057280000

LAST_DML Time in Extract Trail file on Site A is lower (15:28:01.388828000) – so the value for QTY_IN_STOCK which is 1 in that trail file got applied and the trail file on Site B (sent from Site A) which had the value of 11 for QTY_IN_STOCK was not applied.

If we use the stats command with the reportcdr option, we can that CDR has taken place and an UPDATEROWEXISTS tyoe of conflict was resolved.

GGSCI (pdemvrhl061) 1> stats replicat rep1 latest reportcdr

Sending STATS request to REPLICAT REP1 ...

Start of Statistics at 2013-04-11 16:07:30.

Replicating from SH.INVENTORY to SH.INVENTORY:

*** Latest statistics since 2013-04-11 15:08:45 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00
        Total CDR conflicts                                2.00
        CDR resolutions succeeded                          2.00
        CDR UPDATEROWEXISTS conflicts                      2.00

Viewing all articles
Browse latest Browse all 80

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>