aliyun-dts-subscribe-sdk-java icon indicating copy to clipboard operation
aliyun-dts-subscribe-sdk-java copied to clipboard

KafkaRecordFetcher类的mayCommitCheckpoint、setToCommitCheckpoint方法有并发问题

Open songxinjianqwe opened this issue 2 years ago • 0 comments

1、线程A调用了setToCommitCheckpoint,将toCommitCheckpoint更新为1 2、KafkaRecordFetcher线程调用了mayCommitCheckpoint,读到toCommitCheckpoint值为1,然后去commit 位点 3、线程A调用了setToCommitCheckpoint,将toCommitCheckpoint更新为2 4、KafkaRecordFetcher线程继续执行mayCommitCheckpoint方法,位点commit完毕,将toCommitCheckpoint置为空

那么这个时候位点2就丢失掉了,没法被commit了。 一种解法是第4步的时候,比较下toCommitCheckpoint是不是1,如果是1,则置为空,如果不是1,那么不置空

songxinjianqwe avatar May 31 '22 07:05 songxinjianqwe