Skip to content

Commit 50a5149

Browse files
authored
br/stream: allow pitr to create oversized indices (#58433) (#58812)
close #58430
1 parent 84762e9 commit 50a5149

File tree

7 files changed

+34
-8
lines changed

7 files changed

+34
-8
lines changed

br/pkg/task/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestUrlNoQuery(t *testing.T) {
8787

8888
func TestTiDBConfigUnchanged(t *testing.T) {
8989
cfg := config.GetGlobalConfig()
90-
restoreConfig := enableTiDBConfig()
90+
restoreConfig := tweakLocalConfForRestore()
9191
require.NotEqual(t, config.GetGlobalConfig(), cfg)
9292
restoreConfig()
9393
require.Equal(t, config.GetGlobalConfig(), cfg)

br/pkg/task/restore.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
923923
}
924924

925925
// pre-set TiDB config for restore
926-
restoreDBConfig := enableTiDBConfig()
926+
restoreDBConfig := tweakLocalConfForRestore()
927927
defer restoreDBConfig()
928928

929929
if client.GetSupportPolicy() {
@@ -1251,9 +1251,9 @@ func restorePostWork(
12511251
}
12521252
}
12531253

1254-
// enableTiDBConfig tweaks some of configs of TiDB to make the restore progress go well.
1254+
// tweakLocalConfForRestore tweaks some of configs of TiDB to make the restore progress go well.
12551255
// return a function that could restore the config to origin.
1256-
func enableTiDBConfig() func() {
1256+
func tweakLocalConfForRestore() func() {
12571257
restoreConfig := config.RestoreFunc()
12581258
config.UpdateGlobal(func(conf *config.Config) {
12591259
// set max-index-length before execute DDLs and create tables

br/pkg/task/stream.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,9 @@ func restoreStream(
12631263
ctx, cancelFn := context.WithCancel(c)
12641264
defer cancelFn()
12651265

1266+
restoreCfg := tweakLocalConfForRestore()
1267+
defer restoreCfg()
1268+
12661269
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
12671270
span1 := span.Tracer().StartSpan(
12681271
"restoreStream",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# config of tidb
2+
3+
max-index-length = 12288
4+
5+
[security]
6+
ssl-ca = "/tmp/backup_restore_test/certs/ca.pem"
7+
ssl-cert = "/tmp/backup_restore_test/certs/tidb.pem"
8+
ssl-key = "/tmp/backup_restore_test/certs/tidb.key"
9+
cluster-ssl-ca = "/tmp/backup_restore_test/certs/ca.pem"
10+
cluster-ssl-cert = "/tmp/backup_restore_test/certs/tidb.pem"
11+
cluster-ssl-key = "/tmp/backup_restore_test/certs/tidb.key"

br/tests/br_pitr/incremental_data/ingest_repair.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ ALTER TABLE test.pairs9 CHANGE y y2 varchar(20);
4646

4747
-- test partition
4848
ALTER TABLE test.pairs10 ADD INDEX i1(y);
49+
50+
51+
CREATE INDEX huge ON test.huge_idx(blob1, blob2);

br/tests/br_pitr/prepare_data/ingest_repair.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ INSERT INTO test.pairs10 VALUES (1,1,"1"),(2,2,"2"),(3,3,"3"),(4,4,"4"),(5,5,"5"
4343
-- test no need to repair
4444
CREATE TABLE test.pairs11(x int auto_increment primary key, y int DEFAULT RAND(), z int DEFAULT RAND());
4545
INSERT INTO test.pairs11 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
46-
ALTER TABLE test.pairs11 ADD UNIQUE KEY u1(x, y);
46+
ALTER TABLE test.pairs11 ADD UNIQUE KEY u1(x, y);
47+
48+
CREATE TABLE test.huge_idx(id int AUTO_INCREMENT, blob1 varchar(1000), blob2 varchar(1000));

br/tests/br_pitr/run.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ CUR=$(cd `dirname $0`; pwd)
2222
PREFIX="pitr_backup" # NOTICE: don't start with 'br' because `restart services` would remove file/directory br*.
2323
res_file="$TEST_DIR/sql_res.$TEST_NAME.txt"
2424

25+
restart_services_allowing_huge_index() {
26+
echo "restarting services with huge indices enabled..."
27+
stop_services
28+
start_services --tidb-cfg "$CUR/config/tidb-max-index-length.toml"
29+
echo "restart services done..."
30+
}
31+
2532
# start a new cluster
2633
echo "restart a services"
27-
restart_services
34+
restart_services_allowing_huge_index
2835

2936
# prepare the data
3037
echo "prepare the data"
@@ -94,11 +101,11 @@ done
94101

95102
# start a new cluster
96103
echo "restart a services"
97-
restart_services
104+
restart_services_allowing_huge_index
98105

99106
# PITR restore
100107
echo "run pitr"
101-
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/full" > $res_file 2>&1
108+
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/full" > $res_file 2>&1 || ( cat $res_file && exit 1 )
102109

103110
# check something in downstream cluster
104111
echo "check br log"

0 commit comments

Comments
 (0)