Wednesday, May 21, 2014

OGG-01168 - Encountered an update for target table which has no unique key defined. KEYCOLS can be used to define a key...

Was very happy that Golden Gate replication is going smooth until one of the group abended with the following error:

2014-05-21 20:23:15  WARNING OGG-00869  Oracle GoldenGate Delivery for Oracle, RRHP99.prm:  No unique key is defined for table 'SAN_TEST'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.
2014-05-21 20:23:15  ERROR   OGG-01168  Oracle GoldenGate Delivery for Oracle, RRHP99.prm:  Encountered an update for target table EQT6TIW.SAN_TEST, which has no unique key defined.  KEYCOLS can be used to define a key.  Use ALLOWNOOPUPDATES to process the update without applying it to the target database.  Use APPLYNOOPUPDATES to force the update to be applied using all columns in both the SET and WHERE clause.
2014-05-21 20:23:15  ERROR   OGG-01668  Oracle GoldenGate Delivery for Oracle, RRHP99.prm:  PROCESS ABENDING.

The reason for this failure is because there was an update operation that occurred at Source which actually didnt really update any data.

Used parameter ALLOWNOOPUPDATES to get the replicat keep going by ignoring such updates.

I know, there is always a fear as to what will happen to the real update? does this parameter ignores that too? No. It wont. Below is the test that I have performed which illustrates when we get error without that parameter and the real update that does replicates to the target with the parameter:

Source and Target have this table with same structure:

Source-SQL> desc san_test
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NO                                                 NUMBER
 COL1                                               NUMBER(10)

Source-SQL> select * from san_test;

        NO       COL1
---------- ----------
         1          2
         2          2
         3          3
         4          4

At Target:
Target-SQL> select * from san_test;

        NO       COL1
---------- ----------
         1          2
         2          2
         3          3
         4          4

At Source:

Source-SQL> update san_test set no=2 where no=2;

1 row updated.

Source-SQL> commit;

Note the SET value. It is same as the existing.
Now, Replicat Abends with below error message:

2014-05-21 20:23:15  WARNING OGG-00869  Oracle GoldenGate Delivery for Oracle, RRHP99.prm:  No unique key is defined for table 'SAN_TEST'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.
2014-05-21 20:23:15  ERROR   OGG-01168  Oracle GoldenGate Delivery for Oracle, RRHP99.prm:  Encountered an update for target table EQT6TIW.SAN_TEST, which has no unique key defined.  KEYCOLS can be used to define a key.  Use ALLOWNOOPUPDATES to process the update without applying it to the target database.  Use APPLYNOOPUPDATES to force the update to be applied using all columns in both the SET and WHERE clause.
2014-05-21 20:23:15  ERROR   OGG-01668  Oracle GoldenGate Delivery for Oracle, RRHP99.prm:  PROCESS ABENDING.

Add the parameter ALLOWNOOPUPDATES to the prm file and start replicat again.

Now, lets check the update by actually changing the value to make sure it gets replicated.

At Source:
Source-SQL> update san_test set col1=1 where no = 1;

1 row updated.

SQL> commit;

Note the SET value for col1 is different.
At Target:
Target-SQL> select *from san_test;

        NO       COL1
---------- ----------
         1          1
         2          2
         3          3
         4          4

So setting that parameter is only to avoid an unnecessary update and not the real update.

Refer to Oracle Golden Gate Docs on this parameter to obtain more information.

No comments:

Post a Comment