Files
notes/Golden_Gate/example_01/repair_failed_table.md
2026-03-12 22:01:38 +01:00

5.8 KiB

Context

Replicat is ABBENDED because of data issue.
The aim is to restablish the replicat and minimize the downtime.

Provoke a failure on replicat

On target database truncate RED.TRANSACTIONS table:

truncate table RED.TRANSACTIONS;

Replicat will be abbended because of update/delete orders:

status replicat REPLAA
REPLICAT REPLAA: ABENDED 

Remove tablme from replicat

Comment MAP line relative to TRANSACTIONS table on replicat and restart the replicat.

edit params REPLAA

replicat REPLAA
useridalias MAUL
dboptions enable_instantiation_filtering
discardfile REPLAA.dsc, purge, megabytes 10

map YODA.GREEN.ORDERS         , target MAUL.RED.ORDERS            ;
map YODA.GREEN.PRODUCTS       , target MAUL.RED.PRODUCTS          ;
map YODA.GREEN.USERS          , target MAUL.RED.USERS             ;


-- map YODA.GREEN.TRANSACTIONS   , target MAUL.RED.TRANSACTIONS      ;
map YODA.GREEN.TASKS          , target MAUL.RED.TASKS             ;


start replicat REPLAA

At this moment replicat should be RUNNING.

Create a dedicated extract/replicat for the table in failiure

Create a second extract EXTRAB to manage the new tables.
Define extract parameters:

edit params EXTRAB

extract EXTRAB
useridalias JEDIPRD
sourcecatalog YODA
exttrail ./dirdat/ab
purgeoldextracts
checkpointsecs 1
ddl include mapped
warnlongtrans 1h, checkinterval 30m
table GREEN.TRANSACTIONS;

Add, register and start extract:

dblogin useridalias JEDIPRD
add extract EXTRAB, integrated tranlog, begin now
add exttrail ./dirdat/ab, extract EXTRAB
register extract EXTRAB, database container (YODA)
start extract EXTRAB
info extract EXTRAB detail

Start distribution path (aka PUMP) if the replicat is running on distant site (Golden Gate deployment)

Initial load

Note down the current SCN on source database.

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
   12234159

On target DB create tables structure for TRANSACTIONS, TASKS and do the inlitial load:

SCN=12234159
impdp userid=admin/"Secret00!"@togoria/MAUL network_link=GREEN_AT_YODA logfile=MY:import_03.log remap_schema=GREEN:RED tables=GREEN.TRANSACTIONS TABLE_EXISTS_ACTION=TRUNCATE flashback_scn=$SCN

New replicat setup

Define extract parameters. Pay attention to filter(@GETENV ('TRANSACTION','CSN') clause to be setup to SCN of intial datapump load.

edit params REPLAB

replicat REPLAB
useridalias MAUL
dboptions enable_instantiation_filtering
discardfile REPLAB.dsc, purge, megabytes 10

map YODA.GREEN.TRANSACTIONS,       target MAUL.RED.TRANSACTIONS,     filter(@GETENV ('TRANSACTION','CSN') > 12234159);

Add and start new replicat:

add replicat REPLAB, integrated, exttrail ./dirdat/ab
dblogin useridalias SITHPRD
register replicat REPLAB database
start replicat REPLAB
info all

Check if new replicat is running and wait to lag 0.

Reintegrate table to initial extract/replicat

Now, TRANSACTIONS table is replicated by EXTRAB/REPLAB, but not by intial replication EXTRAA/REPLAA. Let's reintegrate TRANSACTIONS in intial replication EXTRAA/REPLAA. Note that TRANSACTIONS was not removed from EXTRAA definition, so all table changes are still recorded in EXTRAA trail files.

Stop extracts in this strictly order:

  • first extract: EXTRAA
  • second extract: EXTRAB

It is mandatory to stop extracts in this order.
The applied SCN on first replicat tables must be less than the SCN on second replicat in order to allow the first replicat to start at the last applied position in the trail file. Like this, the first replicat must not be repositionned in the past.

stop EXTRACT EXTRAA
stop EXTRACT EXTRAB

Now stop both replicat also:

stop replicat REPLAA
stop replicat REPLAB

Note down the SCN for each extract and premare new params file for initial replicat.

info extract EXTRAA detail
info extract EXTRAB detail 

In my case:

  • EXTRAA: SCN=12245651
  • EXTRAB: SCN=12245894

The SCN of EXTRAB should be greater than the SCN of EXTRAA

Update REPLAA replicat parameter file in accordance with the latest SCN applied TRANSACTION table (the SCN of EXTRAB):

edit params REPLAA

replicat REPLAA
useridalias MAUL
dboptions enable_instantiation_filtering
discardfile REPLAA.dsc, purge, megabytes 10

map YODA.GREEN.ORDERS,            target MAUL.RED.ORDERS           ;
map YODA.GREEN.PRODUCTS,          target MAUL.RED.PRODUCTS         ;
map YODA.GREEN.USERS,             target MAUL.RED.USERS            ;
map YODA.GREEN.TASKS,             target MAUL.RED.TASKS            ;

map YODA.GREEN.TRANSACTIONS,      target MAUL.RED.TRANSACTIONS,     filter(@GETENV ('TRANSACTION','CSN') > 12245894);

Start first extract/replicat

start extract EXTRAA 
start replicat REPLAA

When the lag is zero you can remove filter filter(@GETENV ('TRANSACTION','CSN') from REPLAA.

stop replicat REPLAA

edit params REPLAA

replicat REPLAA
useridalias MAUL
dboptions enable_instantiation_filtering
discardfile REPLAA.dsc, purge, megabytes 10

map YODA.GREEN.ORDERS         , target MAUL.RED.ORDERS            ;
map YODA.GREEN.PRODUCTS       , target MAUL.RED.PRODUCTS          ;
map YODA.GREEN.USERS          , target MAUL.RED.USERS             ;
map YODA.GREEN.TASKS          , target MAUL.RED.TASKS             ;

map YODA.GREEN.TRANSACTIONS   , target MAUL.RED.TRANSACTIONS      ;

Restart REPLAA replicat:

start replicat REPLAA

Now all tables are integrated in first extract/replicat.

Remove second extract/replicat

dblogin useridalias JEDIPRD
unregister extract EXTRAB database
delete extract EXTRAB

dblogin useridalias MAUL
unregister replicat REPLAB database
delete replicat REPLAB

Stop and delete distribution path (aka PUMP) if the replicat is running on distant site (Golden Gate deployment).