Skip to content

TiCDC MySQL sink: the max-multi-update-row-size description is misleading #21474

@kennytm

Description

@kennytm

Change Request

Please answer the following questions before submitting your issue. Thanks!

  1. Describe what you find is inappropriate or missing in the existing docs.

https://docs.pingcap.com/tidb/stable/ticdc-sink-to-mysql/

  1. Describe your suggestion or addition.

"Multi-update" is an optimization in TiCDC to merge multiple similar UPDATE statement into a single statement:

UPDATE tbl SET a = 1, b = 2 WHERE pk = 3;
UPDATE tbl SET a = 4, b = 5 WHERE pk = 6;
UPDATE tbl SET a = 7, b = 8 WHERE pk = 9;

-- becomes:
UPDATE tbl SET
    a = CASE WHEN pk = 3 THEN 1 WHEN pk = 6 THEN 4 WHEN pk = 9 THEN 7 END,
    b = CASE WHEN pk = 3 THEN 2 WHEN pk = 6 THEN 5 WHEN pk = 9 THEN 8 END
WHERE pk IN (3, 6, 9);

The transformation is disabled when the update statement is too large, as the complexity outweighs the cost of having multiple statements. The threshold of "large" can be controlled by the parameter max-multi-update-row-size:

| `max-multi-update-row-size` | The size limit of `UPDATE ROWS` SQL statements executed to the downstream when batch write (`batch-dml-enable`) is enabled. If the size exceeds this limit, each row is executed as a separate SQL statement (optional, the default value is `1024`, and the maximum value is `8192`). |

The size limit of UPDATE ROWS SQL statements executed to the downstream when batch write (batch-dml-enable) is enabled. If the size exceeds this limit, each row is executed as a separate SQL statement.

This description suggested the limit is measuring that of the combined "UPDATE SET CASE WHEN" statement. But in reality, this is actually measuring the per-row size before batching. The misunderstanding causes customer confusion, because they are seeing huge batched UPDATE statements downstream with length over 20 KiB despite max-multi-update-row-size is kept as the default 1 KiB.

  1. Provide some reference materials (such as documents and websites) if you could.

CDC source code

Metadata

Metadata

Assignees

Labels

affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.affects-9.0This bug affects the 9.0.x versions.area/ticdcIndicates that the Issue or PR belongs to the area of TiCDC.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions