Skip to content

Commit 0ee0311

Browse files
authored
br/stream: allow pitr to create oversized indices (#58433) (#58529)
close #58430
1 parent 468c62b commit 0ee0311

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

br/pkg/task/common_test.go

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

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

br/pkg/task/restore.go

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

867867
// pre-set TiDB config for restore
868-
restoreDBConfig := enableTiDBConfig()
868+
restoreDBConfig := tweakLocalConfForRestore()
869869
defer restoreDBConfig()
870870

871871
if client.GetSupportPolicy() {
@@ -1183,8 +1183,9 @@ func restorePostWork(
11831183
}
11841184

11851185
// enableTiDBConfig tweaks some of configs of TiDB to make the restore progress go well.
1186+
// tweakLocalConfForRestore tweaks some of configs of TiDB to make the restore progress go well.
11861187
// return a function that could restore the config to origin.
1187-
func enableTiDBConfig() func() {
1188+
func tweakLocalConfForRestore() func() {
11881189
restoreConfig := config.RestoreFunc()
11891190
config.UpdateGlobal(func(conf *config.Config) {
11901191
// 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
@@ -1268,6 +1268,9 @@ func restoreStream(
12681268
ctx, cancelFn := context.WithCancel(c)
12691269
defer cancelFn()
12701270

1271+
restoreCfg := tweakLocalConfForRestore()
1272+
defer restoreCfg()
1273+
12711274
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
12721275
span1 := span.Tracer().StartSpan(
12731276
"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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ INSERT INTO test.pairs10 VALUES (1,1,"1"),(2,2,"2"),(3,3,"3"),(4,4,"4"),(5,5,"5"
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 (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
4646
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ 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
26-
echo "restart a services"
27-
restart_services
33+
restart_services_allowing_huge_index
2834

2935
# prepare the data
3036
echo "prepare the data"
@@ -93,8 +99,7 @@ done
9399
# ...
94100

95101
# start a new cluster
96-
echo "restart a services"
97-
restart_services
102+
restart_services_allowing_huge_index
98103

99104
# PITR restore
100105
echo "run pitr"
@@ -116,8 +121,7 @@ check_contains "DELETE_RANGE_CNT: $expect_delete_range"
116121
bash $CUR/check/check_ingest_repair.sh
117122

118123
# start a new cluster for corruption
119-
echo "restart a services"
120-
restart_services
124+
restart_services_allowing_huge_index
121125

122126
echo "corrupt a log file"
123127
filename=$(find $TEST_DIR/$PREFIX/log -regex ".*\.log" | grep -v "schema-meta" | tail -n 1)

0 commit comments

Comments
 (0)