OGG: Not Able To Register Extract After DB Refresh

After database is refreshed, the following errors occur:

GGSCI> register extract DTCAP database

2024-05-16 01:12:23 ERROR OGG-08221 Cannot register or unregister EXTRACT DTCAP because of the following SQL error: OCI Error ORA (status = 26668-ORA-26668: GoldenGate process OGG$DTCAP exists
ORA-06512: at "SYS.DBMS_XSTREAM_GG_ADM", line 145
ORA-06512: at "SYS.DBMS_XSTREAM_GG_ADM", line 186
ORA-06512: at line 1
).

This is because dictionary tables were not cleaned up properly when OGG process was removed.

set linesize 130
col session_name format a20
col global_db_name format a45

SQL> select SESSION#,CLIENT#,SESSION_NAME,DB_ID,GLOBAL_DB_NAME 
     from system.LOGMNR_SESSION$;

  SESSION# CLIENT# SESSION_NAME DB_ID GLOBAL_DB_NAME
---------- ------- ------------ ---------- ---------
         1      0 OGG$CAP_DTCAP 576966795  PROD     <----OLD PROD DB

Because current DB ID is different from old PROD database one:

SQL> select name, dbid from v$database;

NAME DBID
--------- ----------
TEST 2095324014

Drop the Extract

SQL>SELECT CAPTURE_NAME, CAPTURE_TYPE, STATUS, to_char(REQUIRED_CHECKPOINT_SCN,'999999999999999')as REQ_SCN ,to_char(OLDEST_SCN,'999999999999999')as OLDEST_SCN FROM DBA_CAPTURE;


CAPTURE_NAME                                                                                                                     CAPTURE_TY STATUS   REQ_SCN          OLDEST_SCN
-------------------------------------------------------------------------------------------------------------------------------- ---------- -------- ---------------- ----------------
OGG$CAP_DTCAP                                                                                                                    LOCAL      DISABLED    6217502668722    6215549732638

SQL> exec DBMS_CAPTURE_ADM.DROP_CAPTURE('OGG$CAP_DTCAP');

PL/SQL procedure successfully completed.

SQL> SELECT CAPTURE_NAME, CAPTURE_TYPE, STATUS, to_char(REQUIRED_CHECKPOINT_SCN,'999999999999999')as REQ_SCN ,to_char(OLDEST_SCN,'999999999999999')as OLDEST_SCN FROM DBA_CAPTURE;


no rows selected

Drop queue tables from log miner.

 set linesize 100
col owner format a20
col name format a25
col queue_table format a20
select owner, name, queue_table from dba_queues where owner = 'C##OGGADMIN';

OWNER NAME QUEUE_TABLE
-------------------- ------------------------- --------------------
C##OGGADMIN OGG$Q_DTCAP OGG$Q_TAB_DTCAP
C##OGGADMIN AQ$_OGG$Q_TAB_DTCAP_E OGG$Q_TAB_DTCAP

SQL> exec DBMS_AQADM.DROP_QUEUE_TABLE(queue_table =>'C##OGGADMIN.OGG$Q_TAB_DTCAP', force => TRUE);

PL/SQL procedure successfully completed.

SQL> select queue_table, owner from dba_queues where owner ='C##OGGADMIN';

no rows selected

OR

Stop and clean the queues.

set linesize 100
col owner format a20
col name format a25
col queue_table format a20
select owner, name, queue_table from dba_queues where owner = 'C##OGGADMIN';

OWNER NAME QUEUE_TABLE
-------------------- ------------------------- --------------------
C##OGGADMIN OGG$Q_DTCAP OGG$Q_TAB_DTCAP
C##OGGADMIN AQ$_OGG$Q_TAB_DTCAP_E OGG$Q_TAB_DTCAP

BEGIN
DBMS_AQADM.STOP_QUEUE(queue_name => 'C##OGGADMIN.OGG$Q_DTCAP');
DBMS_AQADM.STOP_QUEUE(queue_name => 'C##OGGADMIN.AQ$_OGG$Q_TAB_DTCAP_E');
DBMS_AQADM.DROP_QUEUE(queue_name => 'C##OGGADMIN.OGG$Q_DTCAP');
DBMS_AQADM.DROP_QUEUE(queue_name => 'C##OGGADMIN.AQ$_OGG$Q_TAB_DTCAP_E');
END;

BEGIN
EXEC DBMS_STREAMS_ADM.REMOVE_QUEUE(
  queue_name => C##OGGADMIN.OGG$Q_DTCAP',
  cascade => true,
  drop_unused_queue_table => true);
END;
/

BEGIN
EXEC DBMS_STREAMS_ADM.REMOVE_QUEUE(  queue_name => 'C##OGGADMIN.AQ$_OGG$Q_TAB_DTCAP_E', 
cascade => true, 
drop_unused_queue_table => true); 
END;
/

SQL> select queue_table, owner from dba_queues where owner ='C##OGGADMIN';

no rows selected


SQL> select SESSION#,CLIENT#,SESSION_NAME,DB_ID,GLOBAL_DB_NAME
from system.LOGMNR_SESSION$;
no rows selected

Not Able To Register Extract After DB Refresh (Doc ID 2593741.1)

Oracle Golden Gate Missing Archive Log Files

OGG extract process is abended due to the missing archive logs as showing in GG error log:

2023-01-21T01:19:23.197+1100  ERROR   OGG-01028  Oracle GoldenGate Capture for Oracle, CAP01.prm:  Could not find archived log for sequence 99 thread 2 under default destinations SQL <SELECT  name   FROM v$archived_log   WHERE sequence# = :1 AND         thread# = :2 AND         resetlogs_id = :3 AND         archived = 'YES' AND         deleted = 'NO'         AND standby_dest = 'NO'         order by name DESC>, error retrieving redo file name for sequence 99, archived = 1, use_alternate = 0.

You can restore the missing archive logs using RMAN from tape backup if they are still available, then restart the extract process.

Otherwise we have to skip the archive log, certainly the data might be missed due to skipping the log files. In this case, let OGG to skip logfile by issuing following command:

GGSCI >ALTER EXTRACT CAP01, extseqno 100

Sometimes we can skip the transactions based on date and time, like :

GGSCI> ALTER EXTRACT CAP01 BEGIN 2024-02-24 15:00

ERROR OGG-01172 Discard file (/home/oracle/ggs/dirrpt/REP01.dsc) exceeded max bytes (3000000)

The replicate process ABENDING due to the following errors exist in replicate process report:

ERROR   OGG-01172  Discard file (/home/oracle/ggs/dirrpt/REP01.dsc) exceeded max bytes (3000000).

SOLUTION

Increase the discardfile maximum size in replicate parameter file from default 3M to 100M:

discardfile /home/oracle/ggs/dirrpt/REP01.dsc, purge, megabytes 100

OGG-00901 Failed to lookup object ID

When starting up OGG extract with the following error in ggserr.log :

ERROR OGG-00901 Failed to lookup object ID for table GG.D7A_GGS_TRACE
ERROR OGG-01668 Oracle GoldenGate Capture for Oracle,CAP.prm:PROCESS ABENDING

Check the parameter file of capture with one line:

tractable GG.D7A_GGS_TRACE

SOLUTION

Manually create trace table as required.

GGSCI>info credentialstore
GGSCI> DBLOGIN USERIDALIAS gg
or
GGSCI>DBLOGIN USERID gg, PASSWORD passwd
GGSCI> INFO TRACETABLE
GGSCI> add tracetable GG.D7A_GGS_TRACE
GGSCI> INFO TRACETABLE
GGSCI>
SQL> desc GG.D7A_GGS_TRACE
Name Null? Type
----------------------------------------- -------- -------------------
GROUP_ID NOT NULL VARCHAR2(8)
DB_USER VARCHAR2(30)
LAST_UPDATE DATE

Add default CHECKPOINTTABLE:

GGSCI> INFO TRACETABLE
GGSCI> ADD CHECKPOINTTABLE
GGSCI> info CHECKPOINTTABLE
SQL> select table_name from dba_tables where owner='GG';

TABLE_NAME
------------------------------
GGS_CHECKPOINT
GGS_CHECKPOINT_LOX
D7A_GGS_TRACE