当transactionCommit()失败时,Oracle GoldenGate Java Adapter丢失了数据

时间:2015-08-24 04:22:20

标签: java oracle oracle-golden-gate

我目前正在开发一个自定义处理程序来提供Oracle更改日志。

当发生一些错误时,通常我会抛出RuntimeException或返回Status.ABEND。然后OGG会记录错误并停止进程。

当operationAdded()失败时,以下代码运行良好(即,Extract进程将报告异常终止,并且当错误后Extract重新启动时,整个失败事务的操作将重新发送给处理程序)。

@Override
public Status operationAdded(DsEvent e, DsTransaction tx,
        DsOperation dsOperation) {
    Status status = super.operationAdded(e, tx, dsOperation);
    ...
    //throw new RuntimeException("op add runtime error");
    return status;
}

但是,当transactionCommit()函数发生错误时,OGG无法按预期工作。既不抛出RuntimeException也不返回Status.ABEND可以停止Extract。 OGG只是一直在努力工作。 (以下代码)

@Override
public Status transactionCommit(DsEvent e, DsTransaction tx) {
    super.transactionCommit(e, tx);
    Status status = sendEvents();
    handlerProperties.totalTxns++;
    //throw new RuntimeException("tx ci runtime error");
    return Status.ABEND;
}

我试图杀死并重新启动Extract进程。失败的事务未重新发送给处理程序。似乎所有失败的交易数据都丢失了!

以下是transactionCommit()中返回Status.ABEND的日志:

...
DEBUG [main] (AbstractHandler.java:509) - Event: handler=ggdatahub, transactionCommit ( Commit transaction ) DsTransaction [ops=1, buffered=1, state=BEGIN, start=2015-08-21 20:04:25.842275, end=2015-08-21 20:04:25.842275]
WARN [main] (DsEventManager.java:231) - Error sending event to handler: status=ABEND, event=Commit transaction, handler=ggdatahub
Exception in thread "main" com.goldengate.atg.util.GGException: Unable to commit transaction, STATUS=ABEND
    at com.goldengate.atg.datasource.UserExitDataSource.commitActiveTransaction(UserExitDataSource.java:1392)
    at com.goldengate.atg.datasource.UserExitDataSource.commitTx(UserExitDataSource.java:1326)
Error occured in javawriter.c[752]:
***********************************************************************
Exception received committing transaction: com.goldengate.atg.util.GGException: Unable to commit transaction, STATUS=ABEND

DEBUG [main] (UserExitDataSource.java:504) - (JNI) C-user-exit checkpoint event
DEBUG [main] (UserExitDataSource.java:1364) - UserExitDataSource.CommitActiveTransaction: Same transaction committed more than once (possibly due to commit-on-checkpoint).
DEBUG [main] (UserExitDataSource.java:516) - UserExitDataSource.userExitCheckpoint: incrementing the flush counter
DEBUG [main] (PendingOpGroup.java:315) - now ready to checkpoint? false (was ready? false): {pendingOps=1, groupSize=0, timer=0:00:00.000 [total = 0 ms ]}
DEBUG [main] (UserExitDataSource.java:504) - (JNI) C-user-exit checkpoint event
DEBUG [main] (UserExitDataSource.java:1364) - UserExitDataSource.CommitActiveTransaction: Same transaction committed more than once (possibly due to commit-on-checkpoint).
DEBUG [main] (UserExitDataSource.java:516) - UserExitDataSource.userExitCheckpoint: incrementing the flush counter
DEBUG [pool-1-thread-1] (AbstractDataSource.java:737) -  [2] getStatusReport: Mon Aug 24 10:51:14 CST 2015
DEBUG [Thread-1] (UserExitDataSource.java:1601) - UserExitDataSource closing, #1 of class=UserExitDataSource
DEBUG [main] (PendingOpGroup.java:315) - now ready to checkpoint? false (was ready? false): {pendingOps=3, groupSize=0, timer=0:00:00.000 [total = 0 ms ]}
DEBUG [Thread-1] (UserExitDataSource.java:1608) - Shutting down data source; attempting a final checkpoint.
INFO [pool-1-thread-1] (AbstractDataSource.java:730) - Memory at Status : Max: 455.00 MB, Total: 60.50 MB, Free: 27.54 MB, Used: 32.96 MB
DEBUG [pool-1-thread-1] (UserExitDataSource.java:1637) - time spent checkpointing: 0:00:00.000 [total = 0 ms ]
DEBUG [Thread-1] (UserExitDataSource.java:1668) - doCheckpoint() called
INFO [pool-1-thread-1] (AbstractDataSource.java:980) - Status report: Mon Aug 24 10:51:14 CST 2015
*************************************************
Status Report for UserExit
*************************************************

Total elapsed time:        2 days 14:47:06.139 [total = 226026 sec = 3767 min = 62 hr ]   => Total time since first event
Event processing time:  0:00:12.692 [total = 12 sec ]   => Time spent sending msgs (max: 4795 ms)
Metadata process time:  0:00:02.159 [total = 2 sec ]   => Time spent receiving metadata (1 tables, 3 columns)

Operations Received/Sent:  3 / 3
 Rate (overall):         0 op/s    (peak: 0 op/s)
      (per event):       0 op/s

Transactions Received/Sent: 2 / 0
 Rate (overall):         0 tx/s    (peak: 0 tx/s)
      (per event):       0 tx/s

3 records processed as of Mon Aug 24 10:51:14 CST 2015 (rate 0/sec, delta 3)

*************************************************

有人知道如何解决这个问题吗?提前谢谢!

1 个答案:

答案 0 :(得分:0)

对于可能遇到此问题的其他人:

事实证明这是一个错误......

我从版本12.1.2.1.4 20470586 OGGCORE_12.1.2.1.0OGGBP_PLATFORMS_150303.1209 转到版本11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230 。现在一切都很好。