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

lightning panic when table name in source file and target cluster is different #31771

Closed
glorv opened this issue Jan 18, 2022 · 1 comment · Fixed by #31808
Closed

lightning panic when table name in source file and target cluster is different #31771

glorv opened this issue Jan 18, 2022 · 1 comment · Fixed by #31808
Assignees
Labels
affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. component/lightning This issue is related to Lightning of TiDB. severity/major type/bug This issue is a bug.

Comments

@glorv
Copy link
Contributor

glorv commented Jan 18, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

provide following source file:

cat test.T.0.sql
insert into T values (1);

manually create target table in target cluster:

create table test.t(id int);

run tidb-lightning with this source file.

The root cause is:

for _, tbl := range schema.Tables {
tblInfo, ok := tableMap[strings.ToLower(tbl.Name)]
if !ok {
return nil, errors.Errorf("table '%s' schema not found", tbl.Name)
}
tableName := tblInfo.Name.String()
if tblInfo.State != model.StatePublic {
err := errors.Errorf("table [%s.%s] state is not public", schema.Name, tableName)
metric.RecordTableCount(metric.TableStatePending, err)
return nil, err
}
metric.RecordTableCount(metric.TableStatePending, err)
if err != nil {
return nil, errors.Trace(err)
}
tableInfo := &checkpoints.TidbTableInfo{
ID: tblInfo.ID,
DB: schema.Name,
Name: tableName,
Core: tblInfo,
}
dbInfo.Tables[tableName] = tableInfo
}

We should also check if other logic has similar issue.

The tableName should use tbl.Name instead of tblInfo.Name.O as they may be different if target table is manually create and is different from tbl.Name.

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

tidb-lightning should import successfully since tidb is case-insensitive

3. What did you see instead (Required)

middle_img_v2_c17cac36-1fcd-4716-b1a4-14f083f9f63g

4. What is your TiDB version? (Required)

v5.3.0

@glorv glorv added type/bug This issue is a bug. severity/major component/lightning This issue is related to Lightning of TiDB. labels Jan 18, 2022
@jebter jebter added the affects-5.3 This bug affects 5.3.x versions. label Jan 19, 2022
YuJuncen pushed a commit to pingcap/br that referenced this issue Mar 1, 2022
@niubell
Copy link
Contributor

niubell commented Apr 13, 2022

/label affects-5.2

@ti-chi-bot ti-chi-bot added the affects-5.2 This bug affects 5.2.x versions. label Apr 13, 2022
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. component/lightning This issue is related to Lightning of TiDB. severity/major type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants