Pages

Wednesday, September 30, 2020

Golden Gate

==========================
Golden gate Checkpoint
==========================

Example:

GGSCI (my_server) 1> INFO ALL

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:03
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:01
EXTRACT     RUNNING     DPM_S_01    00:00:00      00:00:04
EXTRACT     RUNNING     EXT_I_01    00:00:02      00:00:05
EXTRACT     RUNNING     EXT_P_01    00:00:02      00:00:01
EXTRACT     RUNNING     EXT_S_01    00:00:03      00:00:06
REPLICAT    RUNNING     REP_I_01    00:00:00      01:43:12
REPLICAT    RUNNING     REP_P_01    00:00:04      00:00:00
REPLICAT    RUNNING     REP_S_01    00:00:04      00:00:00

Checkpoint Files are under dirchk directory:

oracle@my_server:/software/ogg/191/dirchk>% ls -ltr

-rw-r----- 1 oracle dba  6144 Sep 29 01:00 EXT_I_01.cpb
-rw-r----- 1 oracle dba  6144 Sep 29 01:00 EXT_S_01.cpb
-rw-r----- 1 oracle dba  6144 Sep 29 01:00 EXT_P_01.cpb

-rw-r----- 1 oracle dba 53248 Sep 30 10:54 EXT_S_01.cpe
-rw-r----- 1 oracle dba 69632 Sep 30 10:54 EXT_I_01.cpe
-rw-r----- 1 oracle dba 71680 Sep 30 10:54 EXT_P_01.cpe

-rw-r----- 1 oracle dba 14336 Sep 30 10:54 DPM_S_01.cpe
-rw-r----- 1 oracle dba 14336 Sep 30 10:54 DPM_I_01.cpe
-rw-r----- 1 oracle dba 14336 Sep 30 10:54 DPM_P_01.cpe

-rw-r----- 1 oracle dba 16384 Sep 30 09:12 REP_I_01.cpr
-rw-r----- 1 oracle dba 14336 Sep 30 10:54 REP_P_01.cpr
-rw-r----- 1 oracle dba 16384 Sep 30 10:54 REP_S_01.cpr


Each process in Goldengate has its own checkpoint file which gets updated by default every 10 seconds, if the process is in running status.

Time since checkpoint is the time elapsed since the checkpoint file associated to process was updated.

Lag at checkpoint is the actual lag of the process. It is updated when the checkpoint file was updated.

Sunday, September 13, 2020

REPLICAT is running slow

===========================
General
===========================

Replicat process is running slow. 
What to check?

Quick solution:

SEND REPLICAT REP_I_01 NOHANDLECOLLISIONS OWNER.TABLE 


===========================
Commands
===========================

GGSCI (ITMIL7DB00001) 1> INFO ALL

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:01
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:02
EXTRACT     RUNNING     DPM_S_01    00:00:04      00:00:08
EXTRACT     RUNNING     EXT_I_01    00:00:02      00:00:07
EXTRACT     RUNNING     EXT_P_01    00:00:03      00:00:01
EXTRACT     RUNNING     EXT_S_01    00:00:03      00:00:01
REPLICAT    RUNNING     REP_I_01    83:00:54      03:24:01
REPLICAT    RUNNING     REP_P_01    00:00:00      00:00:00
REPLICAT    RUNNING     REP_S_01    00:00:05      00:00:01


GGSCI (ITMIL7DB00001) 12> SEND REPLICAT REP_I_01 STATUS

Sending STATUS request to REPLICAT REP_I_01 ...
  Current status: Processing data
  Sequence #: 1,046
  RBA: 205,827,294
  116,969 records in current transaction.


GGSCI (ITMIL7DB00001) 13> SEND REPLICAT REP_I_01 GETLAG

Sending GETLAG request to REPLICAT REP_I_01 ...
Last record lag 311,350 seconds.

311350/60/60~86:30


GGSCI (ITMIL7DB00001) 10> SEND REPLICAT REP_I_01 REPORT

Sending REPORT request to REPLICAT REP_I_01 ...
Request processed.

less REP_I_01.rpt
*********************************************************************
*                 ** Run Time Statistics **                         *
*********************************************************************

Last record for the last committed transaction is the following:
___________________________________________________________________
Trail name :  /software/ogg/191/dirdat/01/in/ei000001046
Hdr-Ind    :     E  (x45)     Partition  :     .  (x0c)
UndoFlag   :     .  (x00)     BeforeAfter:     A  (x41)
RecLength  :   512 (x0200)    IO Time    : 2020-09-05 06:29:53.999626
IOType     :   135  (x87)     OrigNode   :   255  (xff)
TransInd   :     .  (x02)     FormatType :     R  (x52)
SyskeyLen  :     0  (x00)     Incomplete :     .  (x00)
AuditRBA   :     157412       AuditPos   : 52390468
Continued  :     N  (x00)     RecCount   :     1  (x01)

2020-09-05 06:29:53.999626 UnifiedPKUpdate    Len   512 RBA 136585873
TDR Index: 1
___________________________________________________________________


2020-09-08 20:56:06  INFO    OGG-02333  Reading /software/ogg/191/dirdat/01/in/ei000001046, current RBA 205,657,982, 904,894 records, m_file_seqno = 1,046, m_file_rba = 205,658,574.

From Table OWNER.SGA_SUBSCRIBER_SFI to OWNER.SGA_SUBSCRIBER_SFI:
       #                   inserts:       100
       #                   updates:    788107
       #                   deletes:         0
       #                   upserts:         0
       #                  discards:         0
       #         update collisions:    394032
From Table OWNER.IPN_INVALIDATE to OWNER.IPN_INVALIDATE:
       #                   inserts:         4
       #                   updates:         0
       #                   deletes:         0
       #                   upserts:         0
       #                  discards:         0
       #                   ignores:        72


*********************************************************************
**                   Run Time Warnings                             **
*********************************************************************

Check if GG is using swap files, under dirtmp
dirtmp is the default location for storing transaction data when the size exceeds the memory size that is allocated for the cache manager. 

oracle@ITMIL7DB00001:/software/ogg/191/dirtmp>% ls -ltr
total 0
srwxr-x---. 1 oracle dba 0 Aug 31 21:39 DPM_I_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:39 EXT_I_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:40 DPM_P_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:40 EXT_P_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:41 REP_P_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:41 DPM_S_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:42 EXT_S_01.s
srwxr-x---. 1 oracle dba 0 Aug 31 21:42 REP_S_01.s
srwxr-x---. 1 oracle dba 0 Sep  8 11:05 REP_I_01.s


Check memory settings in parameter file
rep_i_01.prm
REPLICAT rep_i_01

setenv (ORACLE_SID="igt")
setenv (ORACLE_HOME="/software/oracle/122")
setenv (NLS_LANG = "AMERICAN_AMERICA.AL32UTF8")

ASSUMETARGETDEFS
USERID ogg, PASSWORD AACAAAAAAAAAAAIAZEDCPHICXGPEQCED ENCRYPTKEY DEFAULT

REPERROR (DEFAULT, IGNORE)

SOURCECHARSET PASSTHRU
CACHEMGR CACHESIZE 1024M
HANDLECOLLISIONS
DISCARDFILE /software/ogg/191/dirdat/01/in/disc01i.txt, append, MEGABYTES 2000
include ./dirprm/mapSFItables_01.inc

===========================
Resolution
===========================

Remove NOHANDLECOLLISIONS from Replicat configuration on both sites.
Checking output of STATS command, the replicat is 90% of the time, is busy parsing collisions.

Before NOHANDLECOLLISIONS:

GGSCI (ITMIL7DB00001) 30> SEND REPLICAT REP_I_01 STATS
Sending STATS request to REPLICAT REP_I_01 ...
Start of Statistics at 2020-09-11 20:49:03.
Replicating from OWNER.SGA_SUBSCRIBER_SFI to OWNER.SGA_SUBSCRIBER_SFI:
*** Total statistics since 2020-09-09 07:57:00 ***
        Total inserts                                   7047.00
        Total updates                              159072656.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                                   9701.00
        Total operations                           159079703.00
        Total insert collisions                         1370.00
        Total update collisions                    159071473.00

*** Daily statistics since 2020-09-11 00:00:00 ***
        Total inserts                                   2657.00
        Total updates                               54334620.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                                   9701.00
        Total operations                            54337277.00
        Total insert collisions                          365.00
        Total update collisions                     54333908.00

*** Hourly statistics since 2020-09-11 20:00:00 ***
        Total inserts                                    121.00
        Total updates                                2078586.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                                   9701.00
        Total operations                             2078707.00
        Total insert collisions                           21.00
        Total update collisions                      2078554.00

*** Latest statistics since 2020-09-09 07:57:00 ***
        Total inserts                                   7047.00
        Total updates                              159072656.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                                   9701.00
        Total operations                           159079703.00
        Total insert collisions                         1370.00
        Total update collisions                    159071473.00


Stop Collision Handling for table SGA_SUBSCRIBER_SFI  on both servers, A and B.

SEND REPLICAT REP_I_01 NOHANDLECOLLISIONS OWNER.SGA_SUBSCRIBER_SFI 

After NOHANDLECOLLISIONS

Replicating from OWNER.SGA_SUBSCRIBER_SFI to OWNER.SGA_SUBSCRIBER_SFI:

*** Total statistics since 2020-09-09 07:57:00 ***
        Total inserts                                   8091.00
        Total updates                              159072831.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                               46304442.00
        Total operations                           159080922.00
        Total insert collisions                         1370.00
        Total update collisions                    159071473.00

*** Daily statistics since 2020-09-12 00:00:00 ***
        Total inserts                                    384.00
        Total updates                                     37.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                               20684763.00
        Total operations                                 421.00

*** Hourly statistics since 2020-09-12 02:00:00 ***
        Total inserts                                     48.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total upserts                                      0.00
        Total discards                                     0.00
        Total ignores                                5417534.00
        Total operations                                  50.00

After some time the lag is resolved:

GGSCI (ITMIL7DB00001) 67> INFO ALL

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:06
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:03
EXTRACT     RUNNING     DPM_S_01    00:00:00      00:00:02
EXTRACT     RUNNING     EXT_I_01    00:00:03      00:00:08
EXTRACT     RUNNING     EXT_P_01    00:00:02      00:00:01
EXTRACT     RUNNING     EXT_S_01    00:00:01      00:00:04
REPLICAT    RUNNING     REP_I_01    00:00:00      00:00:05
REPLICAT    RUNNING     REP_P_01    00:00:00      00:00:03
REPLICAT    RUNNING     REP_S_01    00:00:02      00:00:00


===========================
Another scenario - no input file
===========================
GGSCI (qanfv-1-dbs-1a) 1> INFO ALL

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:03
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:01
EXTRACT     RUNNING     DPM_S_01    00:00:00      00:00:01
EXTRACT     RUNNING     EXT_I_01    00:00:02      00:00:02
EXTRACT     RUNNING     EXT_P_01    00:00:01      00:00:01
EXTRACT     RUNNING     EXT_S_01    00:00:01      00:00:05
REPLICAT    RUNNING     REP_I_01    109:56:59     29:07:15
REPLICAT    RUNNING     REP_P_01    00:00:00      00:00:04
REPLICAT    RUNNING     REP_S_01    00:00:00      00:00:01

GGSCI (qanfv-1-dbs-1a) 1> SEND REPLICAT REP_I_01 REPORT

Sending REPORT request to REPLICAT REP_I_01 ...
Request processed.


2020-09-30 09:03:58  INFO    OGG-02333  Reading /software/ogg/191/dirdat/01/in/ei000000016, current RBA 453,246,598, 127,887 records, m_file_seqno = 16, m_file_rba = 453,247,190.

Report at 2020-09-30 09:03:58 (activity since 2020-09-30 07:12:38)

No records were replicated.


ls -l /software/ogg/191/dirdat/01/in/ei000000016
ls: cannot access /software/ogg/191/dirdat/01/in/ei000000016: No such file or directory


first available file is:
/software/ogg/191/dirdat/01/in/ei000000243


GGSCI (qanfv-1-dbs-1a) 1> ALTER REPLICAT REP_I_01 extseqno 243 extrba 0


GGSCI (qanfv-1-dbs-1a) 8>  send REP_I_01 STATUS

Sending STATUS request to REPLICAT REP_I_01 ...
  Current status: Processing data
  Sequence #: 16
  RBA: 457,712,054
  135,430 records in current transaction.
STOP request pending end-of-transaction (135,430 records so far).

Need first to stop the REPLICAT

GGSCI (qanfv-1-dbs-1a) 8>  KILL REP_I_01

GGSCI (qanfv-1-dbs-1a) 16> ALTER REPLICAT REP_I_01 extseqno 243 extrba 0

2020-09-30 09:12:00  INFO    OGG-06594  Replicat REP_I_01 has been altered. Even the start up position might be updated, duplicate suppression remains active in next startup. To override duplicate suppression, start REP_I_01 with NOFILTERDUPTRANSACTIONS option.

REPLICAT altered.

GGSCI (qanfv-1-dbs-1a) 16> START REP_I_01

GGSCI (qanfv-1-dbs-1a) 19> INFO ALL

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:02
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:09
EXTRACT     RUNNING     DPM_S_01    00:00:00      00:00:10
EXTRACT     RUNNING     EXT_I_01    00:00:02      00:00:00
EXTRACT     RUNNING     EXT_P_01    00:00:02      00:00:09
EXTRACT     RUNNING     EXT_S_01    00:00:02      00:00:03
REPLICAT    RUNNING     REP_I_01    00:00:00      00:00:33
REPLICAT    RUNNING     REP_P_01    00:00:00      00:00:06
REPLICAT    RUNNING     REP_S_01    00:00:00      00:00:04

Checking REP_I_01 Report in Intervals

2020-09-30 09:13:55  INFO    OGG-02333  Reading /software/ogg/191/dirdat/01/in/ei000000243, current RBA 642,943, 1,081 records, m_file_seqno = 243, m_file_rba = 643,535.

2020-09-30 09:16:34  INFO    OGG-02333  Reading /software/ogg/191/dirdat/01/in/ei000000243, current RBA 1,695,519, 2,859 records, m_file_seqno = 243, m_file_rba = 1,696,111.



=========================================
HANDLECOLLISIONS/NOHANDLECOLLISIONS
=========================================
Default behavior is NOHANDLECOLLISIONS

Enabling HANDLECOLLISIONS is done to address mismatch in data on two sites.
Golden Gate handles mismatch on below manner:

INSERT Collision
Insert in source whose key column exist on target is converted to update.
Instead of having duplicate insert, the insert is converted to Update.

UPDATE Collision
Updated in source but row not present in target.
- If the row with the old key is not found in the target, the DML is converted to an insert.
- If a row with the new key exists in the target, Replicat deletes the row that has the old key,    and the row with the new key is updated, effectively replacing the old row.

UPDATE Collision - Ignored
When Replicat encounters a missing-record error during an update that does not affect a key column, the change is discarded.

DELETE Collision
Deleted in source but row not present in target
Ignored

=========================================
Setting HANDLECOLLISIONS/NOHANDLECOLLISIONS value
=========================================

Option A - in REPLICAT parameter file + restart the replicat

Option B - As a parameter to SEND REPLICAT command:
SEND REPLICAT SOME_REPLICAT NOHANDLECOLLISIONS OWNER.TABLE_NAME

With Option B, no need for restart.

Additional Oracle Reference:
HANDLECOLLISIONS | NOHANDLECOLLISIONS

=========================================
Plan to revive lagging REPLICAT on a single table
=========================================
1. stop GG
2. stop application
3. drop unique indexes
4. export from site A + import to site B with append mode
5. del duplicates
6. export from site B + import to site A with append mode
7. delete duplicates
8. enable  unique key
9. START REPLICATE XXX BEGIN NOW
10. START EXTRACT XXX BEGIN NOW
11. start application



===========================
Steps to reset Replicat to begin Now
===========================
GGSCI (qanfv-1-dbs-1a) 13> SEND REPLICAT REP_I_01 REPORT

from REP_I_01.rpt
2020-10-05 14:05:00  INFO    OGG-02232  Switching to next trail file /software/ogg/191/dirdat/01/in/ei000000762 at 2020-10-05 14:05:00.576477 due to EOF. with current RBA 499,999,812.

2020-10-05 14:05:21  INFO    OGG-01021  Command received from GGSCI: REPORT.

***********************************************************************
*                   ** Run Time Statistics **                         *
***********************************************************************


2020-10-05 14:05:21  INFO    OGG-02333  Reading /software/ogg/191/dirdat/01/in/ei000000762, current RBA 24,913,169, 106,074 records, m_file_seqno = 762, m_file_rba = 24,913,761.

Report at 2020-10-05 14:05:21 (activity since 2020-10-05 14:04:20)

No records were replicated.



GGSCI (qanfv-1-dbs-1a) 13> ALTER REPLICAT REP_I_01, BEGIN NOW
ERROR: REPLICAT REP_I_01 is running and cannot be altered (1,2,No such file or directory).

GGSCI (qanfv-1-dbs-1a) 14> STOP REPLICAT REP_I_01

Sending STOP request to REPLICAT REP_I_01 ...
STOP request pending end-of-transaction (199,394 records so far).


GGSCI (qanfv-1-dbs-1a) 14> KILL REPLICAT REP_I_01
Killed process (31188) for REPLICAT REP_I_01

GGSCI (qanfv-1-dbs-1a) 16> ALTER REPLICAT REP_I_01, BEGIN NOW

2020-10-05 14:10:53  INFO    OGG-06594  Replicat REP_I_01 has been altered. Even the start up position might be updated, duplicate suppression remains active in next startup. To override duplicate suppression, start REP_I_01 with NOFILTERDUPTRANSACTIONS option.

REPLICAT altered.


GGSCI (qanfv-1-dbs-1a) 17> START REPLICAT REP_I_01

Sending START request to MANAGER ...
REPLICAT REP_I_01 starting

GGSCI (qanfv-1-dbs-1a) 18> INFO ALL

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:09
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:02
EXTRACT     RUNNING     DPM_S_01    00:00:00      00:00:09
EXTRACT     RUNNING     EXT_I_01    00:00:00      00:00:00
EXTRACT     RUNNING     EXT_P_01    00:00:02      00:00:05
EXTRACT     RUNNING     EXT_S_01    00:00:01      00:00:05
REPLICAT    RUNNING     REP_I_01    00:00:00      00:00:06
REPLICAT    RUNNING     REP_P_01    00:00:00      00:00:03
REPLICAT    RUNNING     REP_S_01    00:00:00      00:00:06


Alternative:
Use in REPLICATE prm file INSERTMISSINGUPDATES

Limitation:
It can be used only if Extract logs all columns, and not just the changed colums + PK columns

In Extract:
To have all columns logged, the Extract should have this setting:
ADD SCHEMATRANDATA <MY_SCHEMA> ALLCOLS

In Replicat:
Edit replicat prm file
INSERTMISSINGUPDATES
MAP MY_SCHEMA.*, target MY_SCHEMA.*;

There is an option to reload parameters files, without restart:
REFRESH REPLICAT <EXTRACT GROUP>
REFRESH EXTRACT <EXTRACT GROUP>