diff --git a/pkg/restore/client.go b/pkg/restore/client.go index d62a2a9fb..d7a1528a1 100644 --- a/pkg/restore/client.go +++ b/pkg/restore/client.go @@ -9,7 +9,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "math" "sort" "strconv" "sync" @@ -301,10 +300,7 @@ func (rc *Client) GetTableSchema( dbName model.CIStr, tableName model.CIStr, ) (*model.TableInfo, error) { - info, err := dom.GetSnapshotInfoSchema(math.MaxInt64) - if err != nil { - return nil, errors.Trace(err) - } + info := dom.InfoSchema() table, err := info.TableByName(dbName, tableName) if err != nil { return nil, errors.Trace(err) diff --git a/tests/br_300_small_tables/run.sh b/tests/br_300_small_tables/run.sh new file mode 100644 index 000000000..d02c30d99 --- /dev/null +++ b/tests/br_300_small_tables/run.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# +# Copyright 2020 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu +DB="$TEST_NAME" +TABLES_COUNT=300 + +run_sql "create schema $DB;" + +# generate 300 tables with 1 row content. +i=1 +while [ $i -le $TABLES_COUNT ]; do + run_sql "create table $DB.sbtest$i(id int primary key, k int not null, c char(120) not null, pad char(60) not null);" + run_sql "insert into $DB.sbtest$i values ($i, $i, '$i', '$i');" + i=$(($i+1)) +done + +# backup db +echo "backup start..." +run_br backup db --db "$DB" -s "local://$TEST_DIR/$DB" --pd $PD_ADDR + +# truncate every table +# (FIXME: drop instead of truncate. if we drop then create-table will still be executed and wastes time executing DDLs) +i=1 +while [ $i -le $TABLES_COUNT ]; do + run_sql "truncate $DB.sbtest$i;" + i=$(($i+1)) +done + +# restore db +# (FIXME: shouldn't need --no-schema to be fast, currently the alter-auto-id DDL slows things down) +echo "restore start..." +run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --no-schema + +run_sql "DROP DATABASE $DB;"