For Part 1 click here: Troubleshooting GoldenGate Bidirectional (Active-Active) Replication 1 - Conflict Resolution by Using Odd and Even Sequences
Table of Contents
Document Control
Introduction
1.
Overview of Default Exceptions Handling in GoldenGate
1.1 Description
of Current Setup
1.2
Current GoldenGate Parameter Files
1.3
Current Status of Goldengate Processes
2.
Creating a Collision
2.1 Breaking Current GoldenGate Setup - Inserting Unique Row on SOURCE and
TARGET in Oracle
2.2
Checking GoldenGate Processes State
3. Resolution - Building Macro and Exceptions
3.1.
Explanation of MACRO Parameters
3.2
Creating EXCEPTIONS table in GoldenGate Admin Schema
3.3
Starting Replication with New MACRO Parameters and Logging Exceptions
4. Testing the Macro
and Exceptions Handling
Change Record
Date |
Author |
Version |
Change Reference |
|
|
|
|
|
|
November 27, 2011 |
Vladimir Grigorian |
1.0 |
First Draft |
|
Name |
Position |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Distribution
Copy No. |
Name |
Location |
|
|
|
|
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
This publication may not be reproduced, stored in a retrieval system, or transmitted in whole or in part, in any form, or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior written permission of Vladimir Grigorian.
The purpose of this document is document installation, configuration, testing and monitoring setup of Oracle GoldenGate
In this document details are provided on various parameters, their location and in some cases recommended settings.
This document is intended for:
· DBAs and Architects
Following assumptions have been verified prior to installing and configuring Oracle GoldenGate.
1. All specified Hardware Requirements for customer’s platform have been met.
2. All specified Operating System Requirements for source and destination have been satisfied.
3. All Oracle recommended settings have been set on database level.
Conflicts take place in a bidirectional environment when the same row in a given table
is updated or inserted around the same time on both source and target sites.GoldenGate (unlike Oracle Streams) doesn't have a default conflict resolution routine other than using HANDLECOLLISONS. This option, however, is only recommended to be used during initial load and is beside the point in this document.
If an error is encountered, replicat usually abends (rolls back a transaction and then quits while extract and datapump continue piling up the trail files). If this happens in a large production environment trail files will quickly fill the dirdat directory and most importantly, replication stalls until errors are resolved. In some environments, GoldenGate alert log is periodically truncated which leaves no residual information to troubleshoot with.
To enable detailed exceptions logging and allow continuing replication we will configure exceptions handling with Goldengate macros and GGATE.EXCEPTIONS table.
Lets first test default replication error handling.
In previous document we configured bidirectional replication with the following processes and parameters. GoldenGate does not replicate Oracle database sequences values in an active-active environment. We used odd and even sequences to take care of an issue. The sequences must insert values on the target database from its own sequences. Therefore, to ensure that the source and destination sequences are unique, it is recommended to generate odd and even values to each system. We have done it in previous document. This time will will use the same sequence because we want to intentionally create a collision, but have Goldengate automatically handle it for us and keep records of them in a special EXCEPTIONS table.
We have two servers:
Hostname: | source | target |
Instance (11gR2): | source | target |
Schema: | source | source |
In bidirectional GoldenGate configuration changes made to either
database replicate to the other database in real time. The process works like
this:
esource1 (extract on source) -> psource1 (datapump on source) -> rsource1 (replicat
on target)
etarget1 (extract on target) -> ptarget1 (datapump on target) -> rtarget1 (replicat
on source)
Lets document current replication parameter files (please keep in mind we will have to change some of the parameters later on).
SOURCE | TARGET |
--./GLOBALS on source and target--
GGSCHEMA GGATE CHECKPOINTTABLE GGATE.CHKPTAB |
--./GLOBALS on source and target--
GGSCHEMA GGATE CHECKPOINTTABLE GGATE.CHKPTAB |
------------------------------------------------------------------ -- GoldenGate Manager on source and targget-- -- Last updated on 20111015 by VG -- > -------------------------------------------------------------------- PORT 7809 USERID ggate, PASSWORD oracle AUTOSTART EXTRACT * AUTOSTART REPLICAT * AUTORESTART EXTRACT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 AUTORESTART REPLICAT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2 --Specifies to log the lag time as a warning in the event log LAGCRITICALMINUTES 5 --Specifies how often to report lag info to the event log LAGREPORTMINUTES 60 LAGINFOMINUTES 0 --Manages trail files to conserve space-- PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS |
------------------------------------------------------------------ -- GoldenGate Manager on source and targget-- -- Last updated on 20111015 by VG -- > -------------------------------------------------------------------- PORT 7809 USERID ggate, PASSWORD oracle AUTOSTART EXTRACT * AUTOSTART REPLICAT * AUTORESTART EXTRACT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 AUTORESTART REPLICAT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2 --Specifies to log the lag time as a warning in the event log LAGCRITICALMINUTES 5 --Specifies how often to report lag info to the event log LAGREPORTMINUTES 60 LAGINFOMINUTES 0 --Manages trail files to conserve space-- PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS |
---------------------------------------------------------------------- -- Local extract ESOURCE1 for Source schhema on SOURCE server-- -- Updated on 2011 Nov 18 by VG -- --------------------------------------------------------------------- --extract group-- extract ESOURCE1 --export sid setenv (ORACLE_SID=source) --connection to database-- userid ggate, password oracle --reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 --discard-- DiscardFile dirrpt/DRPROD1.dis, Append DiscardRollover at 02:00 ON SUNDAY --Bidirectional params-- --GETAPPLOPS-- --IGNOREREPLICATES-- --Redo log options-- TRANLOGOPTIONS EXCLUDEUSER ggate COMPLETEARCHIVEDLOGTIMEOUT 600 --bound recovery-- BR BROFF --path and name for local destination trrail-- exttrail /opt/oracle/gg/dirdat/c1 --DDL support-- ddl include mapped objname source.* --DML support-- table source.*; |
------------------------------------------------------------------- -- Local extract etarget1 for SOURCE on TARGET db -- -- Updated on 2011 Nov 18 by VG -- --------------------------------------------------------------------- --extract group-- extract ETARGET1 --export sid setenv (ORACLE_SID=target) --connection to database-- userid ggate, password oracle --reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 --discard-- DiscardFile dirrpt/DRPROD1.dis, Append DiscardRollover at 02:00 ON SUNDAY --Redo log options-- TRANLOGOPTIONS EXCLUDEUSER ggate COMPLETEARCHIVEDLOGTIMEOUT 600 --bidirectional parameters-- --GETAPPLOPS-- --IGNOREREPLICATES-- --bound recovery-- BR BROFF --path and name for local destination trrail-- exttrail /opt/oracle/gg/dirdat/t1 --DDL support-- ddl include mapped objname source.* --DML support-- table source.*; |
-------------------------------------------------------------------- -- DataPump PSOURCE1 for SOURCE schema --- -- Updated on 2011 Nov 18 by VG -- --------------------------------------------------------------------- --dataPump group-- extract PSOURCE1 PassThru --hostname and port for trail-- rmthost target, mgrport 7809 --path and name for remote destination ttrail-- rmttrail /opt/oracle/gg/dirdat/c2 table source.* ; |
-------------------------------------------------------------------- -- DataPump PTARGET1 for SOURCE on TARGEET -- -- Updated on 2011 Nov 18 by VG -- --------------------------------------------------------------------- --dataPump group-- extract ptarget1 PassThru --hostname and port for trail-- rmthost source, mgrport 7809 --path and name for remote destination ttrail-- rmttrail /opt/oracle/gg/dirdat/t2 Table SOURCE.* ; |
------------------------------------------------------------------- -- Replicat for SOURCE Schema on SOURCE server -- -- Last updated by VG -- -------------------------------------------------------------------- --Replicat group -- replicat RTARGET1 --export sid setenv (ORACLE_SID=source) --source and target definitions-- AssumeTargetDefs --target database login -- userid ggate, password oracle --PERFORMANCE PARMETERS-- --Double SQL transaction in 1 operation--- GROUPTRANSOPS 2000 --group similar transactions-- --BATCHSQL-- --error handling-- DDLERROR DEFAULT IGNORE RETRYOP --file for dicarded transaction -- discardfile /opt/oracle/gg/discard/RTARGET1_discard.txt, purge, megabytes 50 --Reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 DiscardRollover at 02:00 ON SUNDAY --ddl support-- --HANDLECOLLISIONS-- --Supress constraints, SUPRESSTRIGGERS iis not available in this version-- DBOPTIONS DEFERREFCONST DDL INCLUDE ALL DDLOPTIONS REPORT DDLERROR 942 DISCARD INCLUDE OPTYPE DROP REPERROR (1403, DISCARD) --Enable tracing-- --TRACE2-- --Specify table mapping --- map source.*, target source.* ; |
------------------------------------------------------------------- -- Replicat for SOURCE Schema on TARGET--- -- Last updated on Nov 18 2011 by VG --< -------------------------------------------------------------------- --Replicat group -- replicat RSOURCE1 --export sid setenv (ORACLE_SID=target) --source and target definitions-- AssumeTargetDefs --target database login -- userid ggate, password oracle --PERFORMANCE PARMETERS-- --Double SQL transaction in 1 operation--- GROUPTRANSOPS 2000 --group similar transactions-- BATCHSQL --error handling-- DDLERROR DEFAULT IGNORE RETRYOP --file for dicarded transaction -- discardfile /opt/oracle/gg/discard/PSOURCE1_discard.txt, purge, megabytes 50 --Reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 DiscardRollover at 02:00 ON SUNDAY --ddl support-- DDL INCLUDE ALL DDLOPTIONS REPORT DDLERROR 942 DISCARD INCLUDE OPTYPE DROP REPERROR (1403, DISCARD) HANDLECOLLISIONS --Specify table mapping --- map source.*, target source.* ; |
Lets check status of GoldenGate processes before we started break things:
SOURCE:
GGSCI (source)
36> info all
Program Status
Group Lag Time Since
Chkpt
MANAGER RUNNING
EXTRACT RUNNING
ESOURCE1 00:00:00 00:00:08
EXTRACT RUNNING
PSOURCE1 00:00:00 00:00:03
REPLICAT RUNNING
RTARGET1 00:00:00 00:00:02
GGSCI (source) 37>
TARGET:
GGSCI (target) 8> info
all
Program Status
Group Lag Time
Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING
ETARGET1 00:00:00 00:00:03
EXTRACT RUNNING
PTARGET1 00:00:00 00:00:02
REPLICAT RUNNING
RSOURCE1 00:00:00 00:00:02
GGSCI (target) 9>
Now lets insert identical record into source, target and then see what happens when target tries to insert this record back into source, which already has it.
SOURCE> insert into customers values (20000000, 'Olympia', '20-NOV-2011', '20-NOV-2011');
Both statements complete on source on target, but replicat RTARGET1 running on
SOURCE server abends, while all other processes on both servers continue
running.
GGSCI (source) 36> info all
Lets check what GoldenGate error log tells us on SOURCE (since replicat runs on this machine)
2011-11-25 23:10:01 INFO OGG-00995 Oracle GoldenGate Delivery for Oracle, rtarget1.prm: REPLICAT RTARGET1 starting.
Now lets check report for RTARGET1:
GGSCI (source) 38> view report rtarget1
As you can see this bidirectional replicat abended because of "ORA-00001: unique constraint (SOURCE.CONST_CUSTOMERS_UNQ) violated." after we successfully inserted the same row on source and then target, which then tried to replicate the same row back to source. This error (along with
the ORA-01403 error) is the most common GoldenGate bidirectional error.
Report and GoldenGate error log provided some useful information, but how do we ensure that:
1) Replicat does not abend but continues processing transactions if this sort of error is encountered?
2) GoldenGate stores indefinitely and provides more details on the error - before/after image, a more detailed error message, timestamp to the milliseconds precision, as opposed to just seconds.
In an effort to configure exceptions handling with GoldenGate parameters and macros and logging this information in a custom table we will have to perform the following steps:
Alter extract and replicat parameters.
These are new parameter files (new parameter mark in red):
SOURCE | TARGET |
--./GLOBALS on source and target--
GGSCHEMA GGATE CHECKPOINTTABLE GGATE.CHKPTAB |
--./GLOBALS on source and target--
GGSCHEMA GGATE CHECKPOINTTABLE GGATE.CHKPTAB |
------------------------------------------------------------------ -- GoldenGate Manager on source and target-- -- Last updated on 20111015 by VG -- ------------------------------------------------------------------- PORT 7809 USERID ggate, PASSWORD oracle AUTOSTART EXTRACT * AUTOSTART REPLICAT * AUTORESTART EXTRACT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 AUTORESTART REPLICAT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2 --Specifies to log the lag time as a warning in the event log LAGCRITICALMINUTES 5 --Specifies how often to report lag info to the event log LAGREPORTMINUTES 60 LAGINFOMINUTES 0 --Manages trail files to conserve space-- PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2 |
------------------------------------------------------------------ -- GoldenGate Manager on source and target-- -- Last updated on 20111015 by VG -- ------------------------------------------------------------------- PORT 7809 USERID ggate, PASSWORD oracle AUTOSTART EXTRACT * AUTOSTART REPLICAT * AUTORESTART EXTRACT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 AUTORESTART REPLICAT *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 60 PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2 --Specifies to log the lag time as a warning in the event log LAGCRITICALMINUTES 5 --Specifies how often to report lag info to the event log LAGREPORTMINUTES 60 LAGINFOMINUTES 0 --Manages trail files to conserve space-- PURGEOLDEXTRACTS /opt/oracle/gg/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2 |
-------------------------------------------------------------------- -- Local extract ESOURCE1 for Source schema -- -- Updated on 2011 Nov 18 by VG -- -------------------------------------------------------------------- --extract group-- extract ESOURCE1 --export sid setenv (ORACLE_SID=source) --connection to database-- userid ggate, password oracle --reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 --discard-- DiscardFile dirrpt/DRPROD1.dis, Append DiscardRollover at 02:00 ON SUNDAY --Bidirectional params-- GETAPPLOPS IGNOREREPLICATES --Get data before images-- GETUPDATEBEFORES --Redo log options-- TRANLOGOPTIONS COMPLETEARCHIVEDLOGTIMEOUT 600 --bound recovery-- BR BROFF --path and name for local destination trail-- exttrail /opt/oracle/gg/dirdat/c1 --DDL support-- ddl include mapped objname source.* --DML support-- table source.*; |
--------------------------------------------------------------------
-- Local extract etarget1 for SOURCE on TARGET db --
-- Updated on 2011 Nov 18 by VG --
--------------------------------------------------------------------
--extract group--
extract ETARGET1
--export sid
setenv (ORACLE_SID=target)
--connection to database--
userid ggate, password oracle
--reporting--
ReportCount Every 30 Minutes, Rate
Report at 01:00
ReportRollover at 01:15
--discard--
DiscardFile /opt/oracle/gg/dirrpt/ETARGET1_discard.dis, Append
DiscardRollover at 02:00 ON SUNDAY
--Redo log options--
TRANLOGOPTIONS EXCLUDEUSER ggate COMPLETEARCHIVEDLOGTIMEOUT 600
--bidirectional parameters--
GETAPPLOPS
IGNOREREPLICATES
--Get data before images--
GETUPDATEBEFORES
--bound recovery--
BR BROFF
--path and name for local destination trail--
exttrail /opt/oracle/gg/dirdat/t1
--DDL support--
ddl include mapped objname source.*
--DML support--
table source.*;
|
-------------------------------------------------------------------- -- DataPump PSOURCE1 for SOURCE schema --- -- Updated on 2011 Nov 18 by VG -- --------------------------------------------------------------------- --dataPump group-- extract PSOURCE1 PassThru --hostname and port for trail-- rmthost target, mgrport 7809 --path and name for remote destination ttrail-- rmttrail /opt/oracle/gg/dirdat/c2 table source.* ; |
-------------------------------------------------------------------- -- DataPump PTARGET1 for SOURCE on TARGEET -- -- Updated on 2011 Nov 18 by VG -- --------------------------------------------------------------------- --dataPump group-- extract ptarget1 PassThru --hostname and port for trail-- rmthost source, mgrport 7809 --path and name for remote destination ttrail-- rmttrail /opt/oracle/gg/dirdat/t2 table SOURCE.* ; |
-- Replicat for SOURCE Schema on SOURCE server -- -- Last updated by VG -- ------------------------------------------------------------------- -- CHECKPARAMS -- This starts the macro -- MACRO #exception_handler BEGIN , TARGET ggate.exceptions , COLMAP ( rep_name = "RTARGET1" , table_name = @GETENV ("GGHEADER", "TABLENAME") , errno = @GETENV ("LASTERR", "DBERRNUM") , dberrmsg = @GETENV ("LASTERR", "DBERRMSG") , optype = @GETENV ("LASTERR", "OPTYPE") , errtype = @GETENV ("LASTERR", "ERRTYPE") , logrba = @GETENV ("GGHEADER", "LOGRBA") , logposition = @GETENV ("GGHEADER", "LOGPOSITION") , committimestamp = @GETENV ("GGHEADER", "COMMITTIMESTAMP") , beforeafter = @GETENV ("GGHEADER", "BEFOREAFTERINDICATOR")) , INSERTALLRECORDS , EXCEPTIONSONLY; END; -- END OF THE MACRO -- --Replicat group -- replicat RTARGET1 --export sid setenv (ORACLE_SID=source) --source and target definitions-- AssumeTargetDefs --target database login -- userid ggate, password oracle --PERFORMANCE PARMETERS-- --Double SQL transaction in 1 operation-- GROUPTRANSOPS 2000 --group similar transactions-- --BATCHSQL-- --error handling-- DDLERROR DEFAULT IGNORE RETRYOP --file for dicarded transaction -- discardfile /opt/oracle/gg/discard/RTARGET1_discard.txt, purge, megabytes 500 --Reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 DiscardRollover at 02:00 ON SUNDAY --ddl support-- --HANDLECOLLISIONS-- --Supress constraints, SUPRESSTRIGGERS is not available in this version-- DBOPTIONS DEFERREFCONST DDL INCLUDE ALL DDLOPTIONS REPORT DDLERROR 942 DISCARD INCLUDE OPTYPE DROP REPERROR (1403, DISCARD) REPERROR (DEFAULT, EXCEPTION) --REPERROR (DEFAULT2, ABEND) REPERROR (DEFAULT2, EXCEPTION) REPERROR (-1, EXCEPTION) --Enable tracing-- --TRACE2-- --Specify table mapping --- map source.*, target source.* ; map source.* #exception_handler(); |
------------------------------------------------------------------- -- Replicat for SOURCE Schema on TARGET--- -- Last updated on Nov 18 2011 by VG --< -------------------------------------------------------------------- --Replicat group -- replicat RSOURCE1 --export sid setenv (ORACLE_SID=target) --source and target definitions-- AssumeTargetDefs --target database login -- userid ggate, password oracle --PERFORMANCE PARMETERS-- --Double SQL transaction in 1 operation--- GROUPTRANSOPS 2000 --group similar transactions-- BATCHSQL --error handling-- DDLERROR DEFAULT IGNORE RETRYOP --file for dicarded transaction -- discardfile /opt/oracle/gg/discard/PSOURCE1_discard.txt, purge, megabytes 50 --Reporting-- ReportCount Every 30 Minutes, Rate Report at 01:00 ReportRollover at 01:15 DiscardRollover at 02:00 ON SUNDAY --ddl support-- DDL INCLUDE ALL DDLOPTIONS REPORT DDLERROR 942 DISCARD INCLUDE OPTYPE DROP REPERROR (1403, DISCARD) HANDLECOLLISIONS --Specify table mapping --- map source.*, target source.* ; |
Lets consider what this new parameters are for.
GETUPDATEBEFORES | IGNOREUPDATEBEFORES
Valid for Extract and Replicat
Use the GETUPDATEBEFORES and IGNOREUPDATEBEFORES parameters to control whether
or not the before images of updated columns are included in the records that are
processed by Oracle GoldenGate. Before images contain column details that
existed before a record was updated. Use the GETUPDATEBEFORES parameter in the
Extract parameter file to extract before images or in the Replicat parameter
file to replicate before images. You can compare before images with after images
to identify the net results of a transaction or perform other delta
calculations. For example, if a BALANCE field is $100 before an update and $120
afterward, a comparison would show the difference of $20. You can use the
column-conversion functions of Oracle GoldenGate to perform the comparisons and
calculations.
You also can use GETUPDATEBEFORES to maintain a transaction-history table. For
more information about performing delta calculations and using transaction
history, see the Oracle GoldenGate Windows and UNIX Administrator’s Guide.
The GETUPDATEBEFORES and IGNOREUPDATEBEFORES parameters are table-specific. One
parameter remains in effect for all subsequent TABLE or MAP statements, until
the other parameter is encountered.
The macro and REPERROR above tell GoldenGate what information should be logged in EXCEPTIONS table and how to handle it establishing a new default . For exmple:
REPERROR (DEFAULT, EXCEPTION) REPERROR (DEFAULT2, ABEND)will abend replicat, while
REPERROR (DEFAULT, EXCEPTION) --REPERROR (DEFAULT2, ABEND) REPERROR (DEFAULT2, EXCEPTION)will make it continue running after logging a transaction.
Now lets put these new parameters to work by stopping extract and replicat, adding the parameters and starting them up but only after we had created exceptions table below:
SOURCE> connect ggate/oracle SOURCE> CREATE TABLE GGATE.EXCEPTIONS ( REP_NAME VARCHAR2(8 BYTE), TABLE_NAME VARCHAR2(61 BYTE), ERRNO NUMBER, DBERRMSG VARCHAR2(4000 BYTE), OPTYPE VARCHAR2(20 BYTE), ERRTYPE VARCHAR2(20 BYTE), LOGRBA NUMBER, LOGPOSITION NUMBER, COMMITTIMESTAMP TIMESTAMP(6), BEFOREAFTER CHAR(1 BYTE) ) TABLESPACE GGATE RESULT_CACHE (MODE DEFAULT) PCTUSED 0 PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K NEXT 1M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT ) LOGGING NOCOMPRESS NOCACHE NOPARALLEL MONITORING; Table created CREATE UNIQUE INDEX GGATE.PK_CTS ON GGATE.EXCEPTIONS (LOGRBA, LOGPOSITION, COMMITTIMESTAMP) LOGGING TABLESPACE GGATE PCTFREE 0 INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 64K NEXT 1M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT ) NOPARALLEL;
Table created
SOURCE> ALTER TABLE GGATE.EXCEPTIONS ADD ( CONSTRAINT PK_CTS PRIMARY KEY (LOGRBA, LOGPOSITION, COMMITTIMESTAMP) USING INDEX GGATE.PK_CTS ENABLE VALIDATE); Constraint Added
Now lets start extract and replicat with the option "ALTER <> BEGIN NOW" with new macro and exceptions handling and make sure replicat is running.
GGSCI (source) 4> info all
Lets run another statement (also identical, but different from the previous one because it will fail, the row already exists):
SOURCE> insert into customers values (20000009, 'Olympia', '20-NOV-2011', '20-NOV-2011');
Lets check if GGATE table has captured the error:
SOURCE> SELECT * FROM GGATE.EXCEPTIONS;
ROW# | REP_NAME | TABLE_NAME | ERRNO | DBERRMSG | OPTYPE | ERRTYPE | LOGRBA | LOGPOSITION | COMMITTIMESTAMP | BEFOREAFTER |
1 | RTARGET1 | SOURCE.CUSTOMERS | 1 |
OCI Error
ORA-00001: unique constraint (SOURCE.CONST_CUSTOMERS_UNQ) violated
(status = 1), SQL <INSERT /*+ RESTRICT_ALL_REF_CONS */ INTO "SOURCE"."CUSTOMERS"
(" CUSTOMER_ID","CUSTOMER_NAME","CUSTOMER_REGISTRATION","CURRDATE") VALUES (:a0,:a1 ,:a2,:a3)> |
INSERT |
DB | 34 | 25134096 | 25-NOV-11 12.08.27.180964 PM | A |
1
row selected
The contents of the table can tell a DBA enough
information about the error.
Also, unlike before replicat continues running despite the error.
At this point we have configured a replicat macro with exceptions handling.
Copyright © 2012 Vladimir Grigorian. All Rights Reserved