Understanding Heartbeat Table End-To-End Replication Flow
The end-to-end replication process for heartbeat tables relies on using the Oracle GoldenGate trail format. The process is as follows:
-
Add a heartbeat table to each of your databases with the
ADD HEARTBEATTABLE
command. Add the heartbeat table to all source and target instances and then restart existing Oracle GoldenGate processes to enable heartbeat functionality. Depending on the database, you may or may not be required to create or enable a job to populate the heartbeat table data.See the following sample:GGSCI>DBLOGIN {[SOURCEDB data_source] |[, database@host:port] |USERID {/ | userid}[, PASSWORD password] [algorithm ENCRYPTKEY {keyname | DEFAULT}] |USERIDALIAS alias [DOMAIN domain]|[SYSDBA | SQLID sqlid][SESSIONCHARSET character_set]} GGSCI>ADD HEARTBEATTABLE
-
(Optional) For Oracle Databases, you must ensure that the Oracle
DBMS_SCHEDULER
is operating correctly as the heartbeat update relies on it. You can query theDBMS_SCHEDULER
by issuing:select START_DATE, LAST_START_DATE, NEXT_RUN_DATE from dba_scheduler_jobs
Where
job_name
='GG_UPDATE_HEARTBEATS';
Then look for valid entries for
NEXT_RUN_DATE
, which is the next time the scheduler will run. If this is a timestamp in the past, then no job will run and you must correct it.A common reason for the scheduler not working is when the parameter
job_queue_processes
is set too low (typically zero). Increase the number ofjob_queue_processes
configured in the database with theALTER SYSTEM SET JOB_QUEUE_PROCESSES = ##;
command where##
is the number of job queue processes. -
Run an Extract, which on receiving the logical change records (LCR) checks the value in the
OUTGOING_EXTRACT
column.-
If the Extract name matches this value, the
OUTGOING_EXTRACT_TS
column is updated and the record is entered in the trail. -
If the Extract name does not match then the LCR is discarded.
-
If the
OUTGOING_EXTRACT
value isNULL
, it is populated along withOUTGOING_EXTRACT_TS
and the record is entered in the trail.
-
-
The Pump or Distribution server on reading the record, checks the value in the
OUTGOING_ROUTING_PATH
column. This column has a list of distribution paths.If the value is
NULL
, the column is updated with the current group name (and path if this is a Distribution server),"*"
, update theOUTGOING_ROUTING_TS
column, and the record is written into its target trail file.If the value has a
"*"
in the list, then replace it withgroup name[:pathname],"*"'
, update theOUTGOING_ROUTING_TS
column, and the record is written into its target trail file. When the value does not have a asterisk (*) in the list and the pump name is in the list, then the record is sent to the path specified in the relevantgroup name[:pathname],"*"'
pair in the list. If the pump name is not in the list, the record is discarded.Run a Replicat, which on receiving the record checks the value in the
OUTGOING_REPLICAT
column.-
If the Replicat name matches the value, the row in the heartbeat table is updated and the record is inserted into the history table.
-
If the Replicat name does not match, the record is discarded.
-
If the value is
NULL
, the row in the heartbeat and heartbeat history tables are updated with an implicit invocation of the Replicat column mapping.Automatic Replicat Column Mapping:
REMOTE_DATABASE = LOCAL_DATABASE INCOMING_EXTRACT = OUTGOING_EXTRACT INCOMING_ROUTING_PATH = OUTGOING_ROUTING_PATH with "*" removed INCOMING_REPLICAT = @GETENV ("GGENVIRONMENT", "GROUPNAME") INCOMING_HEARTBEAT_TS = HEARTBEAT_TIMESTAMP INCOMING_EXTRACT_TS = OUTGOING_EXTRACT_TS INCOMING_ROUTING_TS = OUTGOING_ROUTING_TS INCOMING_REPLICAT_TS = @DATE ('UYYYY-MM-DD HH:MI:SS.FFFFFF','JTSLCT',@GETENV ('JULIANTIMESTAMP')) LOCAL_DATABASE = REMOTE_DATABASE OUTGOING_EXTRACT = INCOMING_EXTRACT OUTGOING_ROUTING_PATH = INCOMING_ROUTING_PATH OUTGOING_HEARTBEAT_TS = INCOMING_HEARTBEAT_TS OUTGOING_REPLICAT = INCOMING_REPLICAT OUTGOING_HEARTBEAT_TS = INCOMING_HEARTBEAT_TS
There is just one column for
OUTGOING_ROUTING_TS
. If a record passes through multiple pump before being applied by a Replicat, each pump will overwrite theOUTGOING_ROUTING_TS
column so that the pumps lag that is calculated is not specific to a single pump and refers to the lag across all the pumps specified inPUMP_PATH
. -
Additional Considerations:
Computing lags as the heartbeat flows through the system relies on the clocks of the source and target systems to be set up correctly. It is possible that the lag can be negative if the target system is ahead of the source system. The lag is shown as a negative number so that you are aware of their clock discrepancy and can take actions to fix it.
The timestamp that flows through the system is in UTC. There is no time zone associated with the timestamp so when viewing the heartbeat tables, the lag can be viewed quickly even if different components are in different time zones. You can write any view you want on top of the underlying tables; UTC is recommended.
All the heartbeat entries are written to the trail in UTF-8.
The outgoing and incoming paths together uniquely determine a row. Meaning that if you have two rows with same outgoing path and a different incoming path, then it is considered two unique entries.
Heartbeat Table Details
The GG_HEARTBEAT
table displays timestamp information of the end-to-end replication time and the timing information at the different components primary and secondary Extract and Replicat.
In a unidirectional environment, only the target database contains information about the replication lag. That is the time when a record is generated at the source database and becomes visible to clients at the target database.
Note:
The automatic heartbeat tables don’t populate the OUTGOING_% columns with data, when both the source and remote databases have the same name. To change the database name, use the utilityDBNEWID
. For details, see the DBNEWID
Utility.
Column | Data Type | Description |
---|---|---|
|
|
Local database where the replication time from the remote database is measured. |
CURRENT_LOCAL_TS 00:00:00 |
DATETIME | |
|
|
The point in time when a timestamp is generated at the remote database. |
|
|
Remote database where the timestamp is generated |
|
|
Name of the primary Extract (capture) at the remote database |
|
|
Name of the secondary Extract (pump) at the remote database |
|
|
Name of the Replicat on the local database. |
|
|
Final timestamp when the information is inserted into the |
|
|
Timestamp of the generated timestamp is processed by the primary Extract at the remote database. |
|
|
Timestamp of the generated timestamp is processed by the secondary Extract at the remote database. |
|
|
Timestamp of the generated timestamp is processed by Replicat at the local database. |
|
|
Bidirectional/N-way replication: Name of the primary Extract on the local database. |
|
|
Bidirectional/N-way replication: Name of the secondary Extract on the local database. |
|
|
Bidirectional/N-way replication: Name of the Replicat on the remote database. |
|
|
Bidirectional/N-way replication: Final timestamp when the information is inserted into the table at the remote database. |
|
|
Bidirectional/N-way replication: Timestamp of the generated timestamp is processed by the primary Extract on the local database. |
|
|
Bidirectional/N-way replication: Timestamp of the generated timestamp is processed by the secondary Extract on the local database. |
|
|
Bidirectional/N-way replication: Timestamp of the generated timestamp is processed by Replicat on the remote database. |
|
|
|
|
|
|
|
|
|
|
|
The GG_HEARTBEAT_HISTORY
table displays historical timestamp information of the end-to-end replication time and the timing information at the different components primary and secondary Extract and Replicat.
In a unidirectional environment, only the destination database contains information about the replication lag.
Timestamps are managed in UTC time zone. That is the time when a record is generated at the source database and becomes visible to clients at the target database.
Column | Data Type | Description |
---|---|---|
|
|
Local database where the end-to-end lag is measured. |
|
|
Point in time when a timestamp from the remote database receives at the local database. |
|
|
Remote database where the timestamp is generated. |
|
|
Name of the primary Extract on the remote database. |
|
|
Name of the secondary Extract of the remote database. |
|
|
Name of the Replicat on the local database. |
|
|
Final timestamp when the information is inserted into the |
|
|
Timestamp when the generated timestamp is processed by the primary Extract on the remote database. |
|
|
Timestamp when the generated timestamp is processed by the secondary Extract on the remote database. |
|
|
Timestamp when the generated timestamp is processed by Replicat on the local database. |
|
|
Bidirectional/N-way replication: Name of the primary Extract from the local database. |
|
|
Bidirectional/N-way replication: Name of the secondary Extract from the local database. |
|
|
Bidirectional/N-way replication: Name of the Replicat on the remote database. |
|
|
Bidirectional/N-way replication: Final timestamp when the information is persistently inserted into the table of the remote database. |
|
|
Bidirectional/N-way replication: Timestamp when the generated timestamp is processed by the primary Extract on the local database. |
|
|
Bidirectional/N-way replication: Timestamp when the generated timestamp is processed by the secondary Extract on the local database. |
|
|
Bidirectional/N-way replication: Timestamp when the generated timestamp is processed by Replicat on the remote database. |
|
|
This column is populated by Replicat when it processes this heartbeat record. It populates this column with its current low watermark (LWM) when it processes this record. This allows us to choose a LOGBSN from a heartbeat record which is as of the Replicat LWM. |
|
|
This column is populated by Extract and contains the source commit SCN for the heartbeat transaction in the source database. The heartbeat job on the source database cannot populate this value as it will not know the commit SCN apriori. |
|
|
This column will be populated by Extract and will contain the current LOGBSN when Extract processes this particular heartbeat record. The heartbeat job on the source database will not populate this value. |
|
|
This column will be populated by Extract and will contain the redo timestamp in UTC that corresponds to the current LOGBSN when Extract processes this particular heartbeat record. The heartbeat job on the source database will not populate this value. |
The GG_LAG
view displays information about the replication lag between the local and remote databases.
In a unidirectional environment, only the destination database contains information about the replication lag. The lag is measured in seconds.
Column | Data Type | Description |
---|---|---|
|
|
Local database where the end-to-end replication lag from the remote database is measured. |
|
|
Current timestamp of the local database. |
|
|
Remote database where the timestamp is generated. |
|
|
The age of the most recent heartbeat received from the remote database. |
|
|
Replication path from the remote database to the local database with Extract and Replicat components. |
|
|
Replication lag from the remote database to the local database. This is the time where the heartbeat where generated at the remote database minus the time where the information was persistently inserted into the table at the local database. |
|
|
The age of the most recent heartbeat from the local database to the remote database. |
|
|
Replication Path from Local database to the remote database with Extract and Replicat components |
|
|
Replication Lag from the local database to the remote database. This is the time where the heartbeat where generated at the local database minus the time where the information was persistently inserted into the table at the remote database. |
|
|
Source Extract restart position. |
|
|
Remote database unique name is displayed. If no unique name exists, then the DB_NAME value is displayed. |
|
Timestamp |
Timestamp associated with source Extract redo position. |
|
Timestamp |
Age of the oldest open transaction at the source database that
Extract is currently processing. This column can be calculated as
|
|
String |
Low watermark CSN of the local Replicat when it processed the heartbeat. |
The GG_LAG_HISTORY
view displays the history information about the replication lag history between the local and remote databases.
In a unidirectional environment, only the destination database contains information about the replication lag.
The unit of the lag units is in seconds.
Column | Data Type | Description |
---|---|---|
|
|
Local database where the end-to-end replication lag from the remote database is measured. |
|
|
Point in time when a timestamp from the remote database receives on the local database. |
|
|
Remote database where the timestamp is generated. |
|
String | Remote database name. |
DB_UNIQUE_NAME |
String | Remote database unique
name. If the database unique name doesn't exist, then the
DB_NAME and DB_UNIQUE_NAME will be
same.
In a switchover to standby scenario, the
|
|
|
The age of the heartbeat table. |
|
|
Replication path from the remote database to local database with Extract and Replicat components. |
|
|
Replication lag from the remote database to the local database. This is the time where the heartbeat was generated at the remote database minus the time where the information was persistently inserted into the table on the local database. |
|
|
|
|
|
Replication path from local database to the remote database with Extract and Replicat components. |
|
|
Replication lag from the local database to the remote database. This is the time where the heartbeat was generated at the local database minus the time where the information was persistently inserted into the table on the remote database. |
|
|
Source Extract restart position. |
|
|
Timestamp associated with source Extract redo position. |
|
|
Age of the oldest open transaction at the source database that
Extract is currently processing. This column can be calculated as:
|
|
|
Low watermark CSN of the local Replicat when it processed the heartbeat. |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|