Why are async commit and binlog incompatible?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 请问为什么async commit和binlog不兼容呢?

| username: Yriuns

The documentation for binlog at TiDB Binlog 简介 | PingCAP 文档中心 states:

TiDB Binlog is incompatible with the following features introduced in TiDB v5.0 and cannot be used together:
* TiDB system variable tidb_enable_async_commit: Enabling this option does not provide performance improvement when TiDB Binlog is enabled. To achieve performance improvement, it is recommended to use TiCDC instead of TiDB Binlog.

Is it because the key in the pump might be commit_ts, and the commit_ts of asynchronous commits is not guaranteed to be unique?

We abstracted Pump into a simple kv database, where the key is the binlog’s start_ts (Priwrite binlog) or commit_ts (Commit binlog), and the value is the binlog’s metadata. The binlog data is stored in data files.

| username: xfworld | Original post link

This article also describes that both start_ts and commit_ts are provided by PD’s TSO. TSO is currently unique, and for transactions, whether optimistic or pessimistic, only one transaction can commit successfully at the same time.

TiCDC’s data processing method is significantly different from TiDB’s binlog solution. Data enters through TiDB’s entry point, and then:

  • TiDB retrieves data through the KV API or DistSQL API provided by TiKV, and records changes when they occur.

  • TiCDC, on the other hand, processes this record through a unified interface for changes after they occur in TiKV.

The main difference lies here…
Hope this helps you.

| username: Yriuns | Original post link

Is it because the commit_ts of async commit is not necessarily obtained from PD, so it is incompatible with binlog?

| username: xfworld | Original post link

I have explained the processing method to you. The way TS is obtained is definitely consistent, but the data processing methods are completely different. ticdc and binlog are definitely incompatible.

| username: Yriuns | Original post link

Maybe I didn’t make myself clear. My question is why async commit and binlog are incompatible, not whether ticdc and binlog are compatible.

| username: xfworld | Original post link

You might not have understood the point.

2PC (Two-Phase Commit transactions) has been simplified to 1PC (One-Phase Commit) [asynchronous commit method].

So, the 2PC that used to be completed on the TiDB node has been simplified to 1PC, which affects the mechanism of TiDB generating binlogs. Essentially, it’s conflicting because TiDB cannot control whether the transaction is committed, thus it cannot capture the transaction change process. However, the TiCDC mechanism just happens to complement this method.