Can TiDB only execute one DDL statement on a table at a time?

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

Original topic: tidb一个表同时只能执行一个DDL语句吗?

| username: wenyi

A table is creating an index, and at the same time, I set the TiFlash replica. The statement to set the TiFlash replica is blocked.

| username: wenyi | Original post link

Is DDL on the same table serialized? Theoretically, creating an index and setting a TiFlash replica are unrelated matters.

| username: TiDBer_C33 | Original post link

DDL operations on the same table must be serialized.

| username: wenyi | Original post link

I am setting the DDL for tiflash and creating an index, not the three types mentioned in this document. I can understand these three types of blocking, but do I need to lock the table?

| username: TiDBer_C33 | Original post link

I understand that if set is considered a DDL operation, it should be no different from what is described in the documentation. I just don’t know if set tiflash counts as a DDL.

| username: wenyi | Original post link

The key is to execute the set tiflash DDL first, then create the index. It’s not blocking and hard to understand.

| username: 这里介绍不了我 | Original post link

Adding an index is in the add index queue, and setting a replica is in the job queue. Theoretically, they should not block each other, but if they involve the same operation object, they will still execute serially.

| username: TiDBer_C33 | Original post link

I haven’t executed set tiflash. Is it a General DDL? General DDL executes very quickly, so if you execute add index again, it shouldn’t block. The blocking situation you encountered was executing add index first and then executing set tiflash, right?

| username: h5n1 | Original post link

Looking at the Job ID and creation time, the index was added first and then the TiFlash replica was set.

| username: TIDB-Learner | Original post link

You added the index operation first, and it has been running for several hours without finishing?

| username: yytest | Original post link

Currently, TiDB already supports online DDL, but only one DDL can be executed at a time, regardless of which TiDB server it is submitted to.

| username: dba远航 | Original post link

DDL operations on the same table must be serialized and executed in queue order.

| username: TiDBer_QYr0vohO | Original post link

Yes, it’s serial.

| username: tidb狂热爱好者 | Original post link

The main issue is that adding indexes is too slow.

| username: tidb狂热爱好者 | Original post link

First, add TiFlash and then add the index. This way, it won’t get stuck.

| username: YuchongXU | Original post link

Serial execution

| username: yytest | Original post link

Online DDL tasks will be persisted to TiKV and executed in a queue.

| username: DBAER | Original post link

It might be caused by metadata.

The introduction below:
To solve this problem, the metadata lock feature was introduced in the online DDL algorithm in TiDB v6.3.0. By coordinating the priority of DML statements and DDL statements during table metadata changes, it allows the executing DDL statements to wait for the DML statements holding the old version of the metadata to commit, thereby avoiding DML statement errors as much as possible.

Setting tiflash should involve two actions, one full and one incremental (this is my personal opinion), equivalent to DML.

| username: 小于同学 | Original post link

DDL needs to be serialized.

| username: 友利奈绪 | Original post link

Serial