pingcap / tiflow

This repo maintains DM (a data migration platform) and TiCDC (change data capture for TiDB)
Apache License 2.0
423 stars 281 forks source link

create table ddl executed too slow when using tidb as the downstream sink #11521

Closed 3AceShowHand closed 1 week ago

3AceShowHand commented 3 weeks ago

What did you do?

run create table ddl on the upstream TiDB.

What did you expect to see?

TiCDC receive and execute ddl should be very quick

What did you see instead?

img_v3_02e1_71b504c8-8e37-4040-a340-2ac72edaa77g

The second log is printed around 23 seconds later after the first one printed.

The root cause is that following query too slow, it may takes more than 20 seconds.

SELECT JOB_ID, JOB_TYPE, SCHEMA_STATE, SCHEMA_ID, TABLE_ID, STATE, QUERY
FROM information_schema.ddl_jobs
WHERE DB_NAME = "%s" 
    AND TABLE_NAME = "%s"
    AND JOB_TYPE LIKE "add index%%"
    AND (STATE = "running" OR STATE = "queueing")
LIMIT 1;
[2024/08/23 18:19:31.924 +08:00] [INFO] [async_ddl.go:165] ["async ddl query success"] [table=test.spmi_transfer_bill206] [duration=23.31010039s]

Versions of the cluster

Upstream TiDB cluster version (execute SELECT tidb_version(); in a MySQL client):

(paste TiDB cluster version here)

Upstream TiKV version (execute tikv-server --version):

(paste TiKV version here)

TiCDC version (execute cdc version):

(paste TiCDC version here)
3AceShowHand commented 3 weeks ago

This is introduced by #11476

lance6716 commented 2 weeks ago

~Maybe the root cause is https://github.com/pingcap/tidb/issues/52905~

We are improving the implementation of I_S tables, you can open a feature request to our team if there's no workaround.