TiDB Multi-Node: Creating a Table on One Node, Unable to Query the Table from Another Node in a Short Time

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

Original topic: tidb多节点,一个节点建表,另外一个节点短时间内查不到表

| username: polars

[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.

| username: zhanggame1 | Original post link

You can script to wait for a period of time.

| username: MrSylar | Original post link

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.

| username: MrSylar | Original post link

F1 Algorithm Paper:

Asynchronous schema change Because there is no global
membership in F1, we cannot synchronize the schema
change across all F1 servers. In other words, different
F1 servers may transition to using a new schema at
different times.

| username: 小龙虾爱大龙虾 | Original post link

The log entry you mentioned is “start ddl job,” which doesn’t prove that it has been completed, right?

| username: polars | Original post link

The status is synced, it should be considered complete, right?

| username: polars | Original post link

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.

| username: 小龙虾爱大龙虾 | Original post link

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.

| username: MrSylar | Original post link

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.

| username: Kongdom | Original post link

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