Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb多节点,一个节点建表,另外一个节点短时间内查不到表
[TiDB Usage Environment] Production/Test
[TiDB Version]
7.5.1, 8.1.0
[Reproduction Path]
There are 2 TiDB nodes.
Create a table through connection 1, and then open connection 2 to execute a query.
When these two connections are not on the same TiDB node, connection 2 may report an error in a short time: table not exists.
[Encountered Problem: Phenomenon and Impact]
You need to manually wait for a period of time before you can query the newly created table on connection 2.
[Resource Configuration] *Enter TiDB Dashboard - Cluster Info - Hosts Screenshot
[Attachment: Screenshot/Log/Monitoring]
As shown in the log below, create table on tidb-1, select on tidb-0, an error will be reported.
You can script to wait for a period of time.
It should be the expected result. The schema version of TiDB is stored in PD, and changes in the schema version are not immediately communicated to all TiDB servers.
The log entry you mentioned is “start ddl job,” which doesn’t prove that it has been completed, right?
The status is synced, it should be considered complete, right?
I understand the reasoning, but applying it is very frustrating. It requires manual polling and waiting on the business code side. In our production environment, sometimes we need to wait for more than a minute, which already affects the user experience. Theoretically, we could add a synchronization mechanism, even if it’s manually triggered.
Yes, but from the logs, I didn’t find the situation you mentioned where one node creates a table and the second node can’t see it.
A quick thought, looking at the code, it seems that loadSchema
is done at 1/2 lease, so is it possible to reduce the lease setting? The impact of the adjustment is uncertain.
I think the person above is right, that is just the start time, not the end time. Execute this to see what the recorded end time is:
ADMIN SHOW DDL JOBS