{"id":2353,"date":"2012-07-10T13:07:52","date_gmt":"2012-07-10T18:07:52","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=2353"},"modified":"2012-07-10T13:07:52","modified_gmt":"2012-07-10T18:07:52","slug":"goldengate-conflict-detection-in-11-2-1-0-and-ignore-when-multiple-statements-are-in-a-transaction","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2012\/07\/10\/goldengate-conflict-detection-in-11-2-1-0-and-ignore-when-multiple-statements-are-in-a-transaction\/","title":{"rendered":"GoldenGate conflict detection in 11.2.1.0 and ignore when multiple statements are in a transaction"},"content":{"rendered":"<p>In GoldenGate 11.2.1.0, they introduced out of the box CDR (conflict detection and resolution).  This is really useful in a bi-directional replication environment such as the one we are building.<\/p>\n<p>One question I had about this surrounded what happened if you handled the conflict on only one statement of a multi statement transaction.  In other words, let&#8217;s say we configured CDR to ignore a missing delete on the target.  Would the other statements in the same transaction still be executed?<\/p>\n<p>The test below shows that the other statements in the transaction are successfully processed.<\/p>\n<p>We start by showing our tables&#8230;<\/p>\n<pre lang=\"text\">\r\nSQL> conn atl\/atl\r\nConnected.\r\nSQL> drop table t1 purge;\r\n\r\nTable dropped.\r\n\r\nSQL> drop table t2 purge;\r\n\r\nTable dropped.\r\n\r\nSQL> create table t1(c int primary key);\r\n\r\nTable created.\r\n\r\nSQL> create table t2(c int primary key);\r\n\r\nTable created.\r\n\r\nSQL> conn cmh\/cmh\r\nConnected.\r\nSQL> drop table t1 purge;\r\n\r\nTable dropped.\r\n\r\nSQL> drop table t2 purge;\r\n\r\nTable dropped.\r\n\r\nSQL> create table t1(c int primary key);\r\n\r\nTable created.\r\n\r\nSQL> create table t2(c int primary key);\r\n\r\nTable created.\r\n\r\nSQL>\r\n<\/pre>\n<p>We then show our CDR rules for these tables in our target replicat parameter file.<\/p>\n<pre lang=\"text\">\r\n----------------------------------------------------------------------------------------------------\r\nmap ATL.T1, target CMH.T1, COMPARECOLS (ON UPDATE ALL, ON DELETE ALL), &\r\nRESOLVECONFLICT (DELETEROWMISSING, (DEFAULT, IGNORE));\r\n----------------------------------------------------------------------------------------------------\r\nmap ATL.T2, target CMH.T2, COMPARECOLS (ON UPDATE ALL, ON DELETE ALL);\r\n----------------------------------------------------------------------------------------------------\r\n<\/pre>\n<p>As you can see above, we ignore any missing delete conflicts on T1.<\/p>\n<p>We then proceed to create a conflict by loading two rows into our source schema tables T1 and T2 as ggadmin so they won&#8217;t be replicated (we ignore any operations by ggadmin).  We also load a row into our CMH.T2 table.  We do this so we can see if the second part of our transaction is completed after ignoring the first transaction that is handled by CDR.  It will need to be handled by CDR as the row to delete won&#8217;t be found in CMH.T1.<\/p>\n<pre lang=\"text\">\r\nSQL> conn ggadmin\/ggadmin\r\nConnected.\r\nSQL> insert into atl.t1 values(1);\r\n\r\n1 row created.\r\n\r\nSQL> insert into atl.t2 values(1);\r\n\r\n1 row created.\r\n\r\nSQL> insert into cmh.t2 values(1);\r\n\r\n1 row created.\r\n\r\nSQL> commit;\r\n\r\nCommit complete.\r\n\r\nSQL>\r\n<\/pre>\n<p>We finally delete our rows in both ATL.T1 and ATL.T2, which are replicated to our target CMH schema.<\/p>\n<pre lang=\"sql\">\r\nSQL> conn atl\/atl\r\nConnected.\r\nSQL> delete from t1;\r\n\r\n1 row deleted.\r\n\r\nSQL> delete from t2;\r\n\r\n1 row deleted.\r\n\r\nSQL> commit;\r\n\r\nCommit complete.\r\n\r\nSQL>\r\n<\/pre>\n<p>After waiting for the transactions to come over, we see that our delete was handled by CDR&#8230;<\/p>\n<pre lang=\"text\">\r\nGGSCI (expressdb1) 1> stats corer, reportcdr, table atl.t1\r\n\r\nSending STATS request to REPLICAT CORER ...\r\n\r\nStart of Statistics at 2012-07-10 13:29:33.\r\n\r\nReplicating from ATL.T1 to CMH.T1:\r\n\r\n*** Total statistics since 2012-07-10 13:28:20 ***\r\n        Total inserts                                      0.00\r\n        Total updates                                      0.00\r\n        Total deletes                                      1.00\r\n        Total discards                                     0.00\r\n        Total operations                                   1.00\r\n        Total CDR conflicts                                1.00\r\n        CDR resolutions succeeded                          1.00\r\n        CDR DELETEROWMISSING conflicts                     1.00\r\n\r\n*** Daily statistics since 2012-07-10 13:28:20 ***\r\n        Total inserts                                      0.00\r\n        Total updates                                      0.00\r\n        Total deletes                                      1.00\r\n        Total discards                                     0.00\r\n        Total operations                                   1.00\r\n        Total CDR conflicts                                1.00\r\n        CDR resolutions succeeded                          1.00\r\n        CDR DELETEROWMISSING conflicts                     1.00\r\n\r\n*** Hourly statistics since 2012-07-10 13:28:20 ***\r\n        Total inserts                                      0.00\r\n        Total updates                                      0.00\r\n        Total deletes                                      1.00\r\n        Total discards                                     0.00\r\n        Total operations                                   1.00\r\n        Total CDR conflicts                                1.00\r\n        CDR resolutions succeeded                          1.00\r\n        CDR DELETEROWMISSING conflicts                     1.00\r\n\r\n*** Latest statistics since 2012-07-10 13:28:20 ***\r\n        Total inserts                                      0.00\r\n        Total updates                                      0.00\r\n        Total deletes                                      1.00\r\n        Total discards                                     0.00\r\n        Total operations                                   1.00\r\n        Total CDR conflicts                                1.00\r\n        CDR resolutions succeeded                          1.00\r\n        CDR DELETEROWMISSING conflicts                     1.00\r\n\r\nEnd of Statistics.\r\n<\/pre>\n<p>&#8230;and show our data was deleted from all tables, including the CMH.T2 delete, which was processed after our CDR routine was run.<\/p>\n<pre lang=\"sql\">\r\nSQL> select * from atl.t1;\r\n\r\nno rows selected\r\n\r\nSQL> select * from atl.t2;\r\n\r\nno rows selected\r\n\r\nSQL> select * from cmh.t1;\r\n\r\nno rows selected\r\n\r\nSQL> select * from cmh.t2;\r\n\r\nno rows selected\r\n\r\nSQL>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In GoldenGate 11.2.1.0, they introduced out of the box CDR (conflict detection and resolution). This is really useful in a bi-directional replication environment such as the one we are building. One question I had about this surrounded what happened if&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2012\/07\/10\/goldengate-conflict-detection-in-11-2-1-0-and-ignore-when-multiple-statements-are-in-a-transaction\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,35],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2353"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2353"}],"version-history":[{"count":9,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2353\/revisions"}],"predecessor-version":[{"id":2362,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2353\/revisions\/2362"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2353"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}