Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb一个表同时只能执行一个DDL语句吗?
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.
Is DDL on the same table serialized? Theoretically, creating an index and setting a TiFlash replica are unrelated matters.
DDL operations on the same table must be serialized.
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?
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.
The key is to execute the set tiflash DDL first, then create the index. It’s not blocking and hard to understand.
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.
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?
Looking at the Job ID and creation time, the index was added first and then the TiFlash replica was set.
You added the index operation first, and it has been running for several hours without finishing?
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.
DDL operations on the same table must be serialized and executed in queue order.
The main issue is that adding indexes is too slow.
First, add TiFlash and then add the index. This way, it won’t get stuck.
Online DDL tasks will be persisted to TiKV and executed in a queue.
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.
DDL needs to be serialized.