Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidb-lightning tidb backend import tableA but report Error 1146: Table 'tableB' doesn't exist #44614

Closed
haiying-gao opened this issue Jun 13, 2023 · 2 comments · Fixed by #44801
Assignees
Labels
affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-7.1 component/lightning This issue is related to Lightning of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@haiying-gao
Copy link

Bug Report

image

during tidb-lightning import another table dropped by someone else.

image

1. Minimal reproduce step (Required)

2. What did you expect to see? (Required)

import successful !

3. What did you see instead (Required)

tidb-lighting report another table not exist.

4. What is your TiDB version? (Required)

tidb-lightning v6.5.2

@haiying-gao haiying-gao added the type/bug The issue is confirmed as a bug. label Jun 13, 2023
@lance6716 lance6716 self-assigned this Jun 13, 2023
@haiying-gao
Copy link
Author

i think the error was introduced by FetchRemoteTableModels funcation.

@aytrack aytrack added the component/lightning This issue is related to Lightning of TiDB. label Jun 14, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Jun 14, 2023
@dsdashun
Copy link
Contributor

The error occurs when the user utilizes the 'tidb' backend to import data. Specifically, at the start of the import process, when Lightning is creating tables, the user drops an irrelevant table in the same database as the data source.

The specific reason for the error message is as follows:
At the beginning of the Lightning task, a list of all the table information that needs to be imported in the data source will be obtained based on the filter and file pattern. This list only contains the table filtered out by the filter.

Next, Lightning will iterate over all the databases involved in the data to be imported before and after executing the statement to restore the corresponding table structure. Then, each database will obtain all the existing table structures to form a map. The purpose of constructing this map is to:

  1. Before creating the table, iterate through the list of tables to be imported, search the map for whether the table name to be imported already exists in the existing database. If it already exists, then there is no need to create the table.
  2. After creating the table, iterate through the list of tables to be imported, search the corresponding table structure information in the map based on the table name to be imported, for subsequent use.

Therefore, the full table structure acquisition strategy is used when constructing this map, and then further filtered based on the list of tables to be imported.

The user's error occurred during the stage of restoring the table structure. At that time, Lightning was constructing this map, and an error occurred when executing SHOW TABLE <table_name> NEXT_ROW_ID to obtain the row ID information of the table, which had been deleted.

Lightning can consider optimizing this process. For example, when encountering this type of error, it can continue to construct the remaining map elements. Because the information in this map, minus one irrelevant table, will not affect the import.

@dsdashun dsdashun added affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-7.1 and removed may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-7.1 labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-7.1 component/lightning This issue is related to Lightning of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants