Skip to content

Commit 4194e2a

Browse files
YuJuncenti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#58433
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 92720ee commit 4194e2a

File tree

7 files changed

+75
-10
lines changed

7 files changed

+75
-10
lines changed

br/pkg/task/common_test.go

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

4444
func TestTiDBConfigUnchanged(t *testing.T) {
4545
cfg := config.GetGlobalConfig()
46-
restoreConfig := enableTiDBConfig()
46+
restoreConfig := tweakLocalConfForRestore()
4747
require.NotEqual(t, config.GetGlobalConfig(), cfg)
4848
restoreConfig()
4949
require.Equal(t, config.GetGlobalConfig(), cfg)

br/pkg/task/restore.go

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

842842
// pre-set TiDB config for restore
843-
restoreDBConfig := enableTiDBConfig()
843+
restoreDBConfig := tweakLocalConfForRestore()
844844
defer restoreDBConfig()
845845

846846
if client.GetSupportPolicy() {
@@ -1098,6 +1098,7 @@ func filterRestoreFiles(
10981098
return
10991099
}
11001100

1101+
<<<<<<< HEAD
11011102
// restorePreWork executes some prepare work before restore.
11021103
// TODO make this function returns a restore post work.
11031104
func restorePreWork(ctx context.Context, client *restore.Client, mgr *conn.Mgr, switchToImport bool) (pdutil.UndoFunc, *pdutil.ClusterConfig, error) {
@@ -1134,8 +1135,11 @@ func restorePostWork(
11341135
}
11351136

11361137
// enableTiDBConfig tweaks some of configs of TiDB to make the restore progress go well.
1138+
=======
1139+
// tweakLocalConfForRestore tweaks some of configs of TiDB to make the restore progress go well.
1140+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))
11371141
// return a function that could restore the config to origin.
1138-
func enableTiDBConfig() func() {
1142+
func tweakLocalConfForRestore() func() {
11391143
restoreConfig := config.RestoreFunc()
11401144
config.UpdateGlobal(func(conf *config.Config) {
11411145
// 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
@@ -1262,6 +1262,9 @@ func restoreStream(
12621262
ctx, cancelFn := context.WithCancel(c)
12631263
defer cancelFn()
12641264

1265+
restoreCfg := tweakLocalConfForRestore()
1266+
defer restoreCfg()
1267+
12651268
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
12661269
span1 := span.Tracer().StartSpan(
12671270
"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: 48 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,11 +99,16 @@ done
9399
# ...
94100

95101
# start a new cluster
102+
<<<<<<< HEAD
96103
echo "restart a services"
97104
restart_services
105+
=======
106+
restart_services_allowing_huge_index
107+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))
98108

99109
# PITR restore
100110
echo "run pitr"
111+
<<<<<<< HEAD
101112
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
102113

103114
# check something in downstream cluster
@@ -114,10 +125,42 @@ expect_delete_range=$(($incremental_delete_range_count-$prepare_delete_range_cou
114125
check_contains "DELETE_RANGE_CNT: $expect_delete_range"
115126
## check feature compatibility between PITR and accelerate indexing
116127
bash $CUR/check/check_ingest_repair.sh
128+
=======
129+
run_sql "DROP DATABASE __TiDB_BR_Temporary_Log_Restore_Checkpoint;"
130+
run_sql "DROP DATABASE __TiDB_BR_Temporary_Custom_SST_Restore_Checkpoint;"
131+
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 )
132+
133+
check_result
134+
135+
# start a new cluster for incremental + log
136+
restart_services_allowing_huge_index
137+
138+
echo "run snapshot restore#2"
139+
run_br --pd $PD_ADDR restore full -s "local://$TEST_DIR/$PREFIX/full"
140+
141+
echo "run incremental restore + log restore"
142+
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/inc" > $res_file 2>&1
143+
144+
check_result
145+
146+
# start a new cluster for incremental + log
147+
echo "restart services"
148+
restart_services_allowing_huge_index
149+
150+
echo "run snapshot restore#3"
151+
run_br --pd $PD_ADDR restore full -s "local://$TEST_DIR/$PREFIX/full"
152+
153+
echo "run incremental restore but failed"
154+
restore_fail=0
155+
run_br --pd $PD_ADDR restore full -s "local://$TEST_DIR/$PREFIX/inc_fail" || restore_fail=1
156+
if [ $restore_fail -ne 1 ]; then
157+
echo 'pitr success on incremental restore'
158+
exit 1
159+
fi
160+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))
117161

118162
# start a new cluster for corruption
119-
echo "restart a services"
120-
restart_services
163+
restart_services_allowing_huge_index
121164

122165
file_corruption() {
123166
echo "corrupt the whole log files"
@@ -143,8 +186,7 @@ if [ $restore_fail -ne 1 ]; then
143186
fi
144187

145188
# start a new cluster for corruption
146-
echo "restart a services"
147-
restart_services
189+
restart_services_allowing_huge_index
148190

149191
file_lost() {
150192
echo "lost the whole log files"

0 commit comments

Comments
 (0)