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

br, ddl: BR restore failure - incremental restore a backup contains primary key and unique key #31835

Closed
fengou1 opened this issue Jan 20, 2022 · 1 comment · Fixed by #31845
Assignees
Labels
component/br This issue is related to BR of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@fengou1
Copy link
Contributor

fengou1 commented Jan 20, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. on nightly build, create a cluster

  2. execute sql
    drop schema if exists db;
    create schema db;
    create table db.t1 (a int primary key nonclustered, b int unique);
    insert into db.t1 values (42, 42);

  3. take backup 1
    ./br backup db --db "db" --pd "172.16.4.2:2379" --storage "local:///backup/db"

  4. execute sql
    create table db.t1inc (a int primary key nonclustered, b int unique);
    insert into db.t1inc values (42, 42);
    alter table db.t1inc drop primary key;
    drop table db.t1inc;
    create table db.t1inc like db.t1;
    insert into db.t1inc values (42, 42);

  5. take backup 2
    ./br backup db --db "db" --pd "172.16.4.2:2379" --storage "local:///backup/dbinc"

  6. execute sql
    drop schema db;

  7. restore backup 1
    ./br restore db --db "db" --pd "172.16.4.2:2379" --storage "local:///backup/db/"

  8. restore backup 2
    ./br restore db --db "db" --pd "172.16.4.2:2379" --storage "local:///backup/dbinc/

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

the second restore of step 8 shall succeed.

3. What did you see instead (Required)

the second restore of step 8 is failure, key failure log:
[2022-01-17T10:00:42.962Z] [2022/01/17 18:00:42.868 +08:00] [DEBUG] [txn.go:479] ["[kv] rollback txn"] [txnStartTS=430548881992581126] [2022-01-17T10:00:42.962Z] [2022/01/17 18:00:42.868 +08:00] [WARN] [glue.go:167] ["batch create table from tidb failure"] [error="[meta:1146]table doesn't exist"] [errorVerbose="[meta:1146]table doesn't exist\ngithub.com/pingcap/errors.AddStack\n\t/go/pkg/mod/github.com/pingcap/[email protected]/errors.go:174\ngithub.com/pingcap/errors.(*Error).GenWithStack\n\t/go/pkg/mod/github.com/pingcap/[email protected]/normalize.go:155\ngithub.com/pingcap/tidb/meta.(*Meta).checkTableExists\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/meta/meta.go:272\ngithub.com/pingcap/tidb/meta.(*autoIDAccessor).Inc\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/meta/meta_autoid.go:63\ngithub.com/pingcap/tidb/meta/autoid.(*allocator).rebase4Signed.func2\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/meta/autoid/autoid.go:358\ngithub.com/pingcap/tidb/kv.RunInNewTxn\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/kv/txn.go:49\ngithub.com/pingcap/tidb/meta/autoid.(*allocator).rebase4Signed\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/meta/autoid/autoid.go:333\ngithub.com/pingcap/tidb/meta/autoid.(*allocator).Rebase\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/meta/autoid/autoid.go:419\ngithub.com/pingcap/tidb/ddl.(*ddl).handleAutoIncID\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/ddl/ddl_api.go:2519\ngithub.com/pingcap/tidb/ddl.(*ddl).createTableWithInfoPost\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/ddl/ddl_api.go:2117\ngithub.com/pingcap/tidb/ddl.(*ddl).BatchCreateTableWithInfo\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/ddl/ddl_api.go:2251\ngithub.com/pingcap/tidb/br/pkg/gluetidb.(*tidbSession).CreateTables\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/br/pkg/gluetidb/glue.go:162\ngithub.com/pingcap/tidb/br/pkg/restore.(*DB).CreateTables\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/br/pkg/restore/db.go:192\ngithub.com/pingcap/tidb/br/pkg/restore.(*Client).createTables\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/br/pkg/restore/client.go:427\ngithub.com/pingcap/tidb/br/pkg/restore.(*Client).createTablesInWorkerPool.func1\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/br/pkg/restore/client.go:618\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyWithIDInErrorGroup.func1\n\t/home/jenkins/agent/workspace/br_ghpr_unit_and_integration_test/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:82\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1371"]

4. What is your TiDB version? (Required)

Only nightly build / master branch

nightly build

it is possible to be introduced by batch create table (batch ddl)

@fengou1 fengou1 added the type/bug The issue is confirmed as a bug. label Jan 20, 2022
@fengou1 fengou1 added component/br This issue is related to BR of TiDB. severity/major labels Jan 20, 2022
@fengou1 fengou1 changed the title br: BR restore failure - incremental restore a backup contains primary key and unique key br, ddl: BR restore failure - incremental restore a backup contains primary key and unique key Jan 20, 2022
ti-chi-bot pushed a commit that referenced this issue Jan 21, 2022
@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

YuJuncen pushed a commit to pingcap/br that referenced this issue Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/br This issue is related to BR 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.

2 participants