Skip to content

Commit 4468f56

Browse files
authored
br/stream: allow pitr to create oversized indices (#58433) (#58527)
close #58430
1 parent b454755 commit 4468f56

File tree

7 files changed

+42
-16
lines changed

7 files changed

+42
-16
lines changed

br/pkg/task/common_test.go

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

100100
func TestTiDBConfigUnchanged(t *testing.T) {
101101
cfg := config.GetGlobalConfig()
102-
restoreConfig := enableTiDBConfig()
102+
restoreConfig := tweakLocalConfForRestore()
103103
require.NotEqual(t, config.GetGlobalConfig(), cfg)
104104
restoreConfig()
105105
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
@@ -972,7 +972,7 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
972972
}
973973

974974
// pre-set TiDB config for restore
975-
restoreDBConfig := enableTiDBConfig()
975+
restoreDBConfig := tweakLocalConfForRestore()
976976
defer restoreDBConfig()
977977

978978
if client.GetSupportPolicy() {
@@ -1407,9 +1407,9 @@ func filterRestoreFiles(
14071407
return
14081408
}
14091409

1410-
// enableTiDBConfig tweaks some of configs of TiDB to make the restore progress go well.
1410+
// tweakLocalConfForRestore tweaks some of configs of TiDB to make the restore progress go well.
14111411
// return a function that could restore the config to origin.
1412-
func enableTiDBConfig() func() {
1412+
func tweakLocalConfForRestore() func() {
14131413
restoreConfig := config.RestoreFunc()
14141414
config.UpdateGlobal(func(conf *config.Config) {
14151415
// 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
@@ -1287,6 +1287,9 @@ func restoreStream(
12871287
ctx, cancelFn := context.WithCancel(c)
12881288
defer cancelFn()
12891289

1290+
restoreCfg := tweakLocalConfForRestore()
1291+
defer restoreCfg()
1292+
12901293
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
12911294
span1 := span.Tracer().StartSpan(
12921295
"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: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ PREFIX="pitr_backup" # NOTICE: don't start with 'br' because `restart services`
2323
res_file="$TEST_DIR/sql_res.$TEST_NAME.txt"
2424
TASK_NAME="br_pitr"
2525

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

3036
# prepare the data
3137
echo "prepare the data"
@@ -92,8 +98,7 @@ check_result() {
9298
}
9399

94100
# start a new cluster
95-
echo "restart services"
96-
restart_services
101+
restart_services_allowing_huge_index
97102

98103
# non-compliant operation
99104
echo "non compliant operation"
@@ -107,13 +112,17 @@ fi
107112
# PITR restore
108113
echo "run pitr"
109114
run_sql "DROP DATABASE __TiDB_BR_Temporary_Log_Restore_Checkpoint;"
115+
<<<<<<< HEAD
110116
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
117+
=======
118+
run_sql "DROP DATABASE __TiDB_BR_Temporary_Custom_SST_Restore_Checkpoint;"
119+
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 )
120+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))
111121

112122
check_result
113123

114124
# start a new cluster for incremental + log
115-
echo "restart services"
116-
restart_services
125+
restart_services_allowing_huge_index
117126

118127
echo "run snapshot restore#2"
119128
run_br --pd $PD_ADDR restore full -s "local://$TEST_DIR/$PREFIX/full"
@@ -125,7 +134,7 @@ check_result
125134

126135
# start a new cluster for incremental + log
127136
echo "restart services"
128-
restart_services
137+
restart_services_allowing_huge_index
129138

130139
echo "run snapshot restore#3"
131140
run_br --pd $PD_ADDR restore full -s "local://$TEST_DIR/$PREFIX/full"
@@ -139,8 +148,7 @@ if [ $restore_fail -ne 1 ]; then
139148
fi
140149

141150
# start a new cluster for corruption
142-
echo "restart a services"
143-
restart_services
151+
restart_services_allowing_huge_index
144152

145153
file_corruption() {
146154
echo "corrupt the whole log files"
@@ -166,8 +174,7 @@ if [ $restore_fail -ne 1 ]; then
166174
fi
167175

168176
# start a new cluster for corruption
169-
echo "restart a services"
170-
restart_services
177+
restart_services_allowing_huge_index
171178

172179
file_lost() {
173180
echo "lost the whole log files"

0 commit comments

Comments
 (0)