一.概要
前段时间,一个朋友问我关于goldengate中的Lag的问题。因涉及到Lag的详细行程过程,而我一直觉得Lag就是: 本进程处理一条记录的时间点和前一个进程处理该记录时的时间点的差距,因为一般情况下都是目标端的REP进程出现LAG的机会比较大,平时也更加侧重于如何去诊断LAG和优化,所以当纠结一些详细原因的时候就卡住了(到底是不是当前处理时间和源库产生的时间)。那既然要更加明确Lag是怎么回事,就需要了解ogg的checkpoint和Lag的原理。以下是相关官方文档的说法:
Checkpoints store the current read and write positions of a process to disk for recovery purposes. Checkpoints ensure that data changes that are marked for synchronization actually are captured by Extract and applied to the target by Replicat, and they prevent redundant processing. They provide fault tolerance by preventing the loss of data should the system, the network, or an Oracle GoldenGate process need to be restarted. For complex synchronization configurations, checkpoints enable multiple Extract or Replicat processes to read from the same set of trails. Checkpoints work with inter-process acknowledgments to prevent messages from being lost in the network. Oracle GoldenGate has a proprietary guaranteed-message delivery technology.(通过这一段,说明checkpoint是用于记录进程当前到底处理到哪个位置的,这个checkpoint是用于防止数据的丢失和重复应用的。)
Extract creates checkpoints for its positions in the data source and in the trail. Because Extract only captures committed transactions, it must keep track of operations in all open transactions, in the event that any of them are committed. This requires Extract to record
a checkpoint where it is currently reading in a transaction log, plus the position of the start of the oldest open transaction, which can be in the current or any preceding log. To control the amount of transaction log that must be re-processed after an outage, Extract persists the current state and data of processing to disk at specific intervals, including the state and data (if any) of long-running transactions. If Extract stops after one of these intervals, it can recover from a position within the previous interval or at the last checkpoint, instead of having to return to the log position where the oldest open longrunning transaction first appeared. For more information, see the BR parameter in the Oracle GoldenGate Windows and UNIX Referen