Skip to content

Commit

Permalink
br: add a test for cached table (#31191) (#44943)
Browse files Browse the repository at this point in the history
close #31190
  • Loading branch information
ti-chi-bot authored Jun 29, 2023
1 parent d05b994 commit 2a463d7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ func BuildBackupRangeAndSchema(
tableInfo.ClearPlacement()
}

// Treat cached table as normal table.
tableInfo.TableCacheStatusType = model.TableCacheStatusDisable

if tableInfo.PKIsHandle && tableInfo.ContainsAutoRandomBits() {
// this table has auto_random id, we need backup and rebase in restoration
var globalAutoRandID int64
Expand Down
42 changes: 42 additions & 0 deletions br/tests/br_cache_table/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eu
DB="$TEST_NAME"

run_sql "create schema $DB;"
run_sql "create table $DB.cache_1 (id int);"
run_sql "insert into $DB.cache_1 values (1);"
run_sql "alter table $DB.cache_1 cache;"
run_sql "insert into $DB.cache_1 values (2),(3);"

echo "backup start..."
run_br backup db --db "$DB" -s "local://$TEST_DIR/$DB" --pd $PD_ADDR

run_sql "drop schema $DB;"

echo "restore start..."
run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR

set -x

run_sql "select count(*) from $DB.cache_1;"
check_contains 'count(*): 3'

run_sql "select create_options from information_schema.tables where table_schema = '$DB' and table_name = 'cache_1';"
check_not_contains 'create_options: cached=on'

run_sql "drop schema $DB"

0 comments on commit 2a463d7

Please sign in to comment.