Skip to content

Commit bfe838f

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 738a65b commit bfe838f

File tree

7 files changed

+113
-7
lines changed

7 files changed

+113
-7
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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
864864
}
865865

866866
// pre-set TiDB config for restore
867-
restoreDBConfig := enableTiDBConfig()
867+
restoreDBConfig := tweakLocalConfForRestore()
868868
defer restoreDBConfig()
869869

870870
if client.GetSupportPolicy() {
@@ -1146,6 +1146,7 @@ func filterRestoreFiles(
11461146
return
11471147
}
11481148

1149+
<<<<<<< HEAD
11491150
// restorePreWork executes some prepare work before restore.
11501151
// TODO make this function returns a restore post work.
11511152
func restorePreWork(ctx context.Context, client *restore.Client, mgr *conn.Mgr, switchToImport bool) (pdutil.UndoFunc, *pdutil.ClusterConfig, error) {
@@ -1182,8 +1183,11 @@ func restorePostWork(
11821183
}
11831184

11841185
// enableTiDBConfig tweaks some of configs of TiDB to make the restore progress go well.
1186+
=======
1187+
// tweakLocalConfForRestore tweaks some of configs of TiDB to make the restore progress go well.
1188+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))
11851189
// return a function that could restore the config to origin.
1186-
func enableTiDBConfig() func() {
1190+
func tweakLocalConfForRestore() func() {
11871191
restoreConfig := config.RestoreFunc()
11881192
config.UpdateGlobal(func(conf *config.Config) {
11891193
// 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ 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+
<<<<<<< HEAD
48+
=======
49+
50+
CREATE TABLE test.huge_idx(id int AUTO_INCREMENT, blob1 varchar(1000), blob2 varchar(1000));
51+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))

br/tests/br_pitr/run.sh

Lines changed: 84 additions & 4 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,17 +125,86 @@ 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

165+
<<<<<<< HEAD
122166
echo "corrupt a log file"
123167
filename=$(find $TEST_DIR/$PREFIX/log -regex ".*\.log" | grep -v "schema-meta" | tail -n 1)
124168
filename_temp=$filename"_temp"
125169
filename_bak=$filename"_bak"
126170
echo "corruption" > $filename_temp
127171
cat $filename >> $filename_temp
172+
=======
173+
file_corruption() {
174+
echo "corrupt the whole log files"
175+
for filename in $(find $TEST_DIR/$PREFIX/log -regex ".*\.log" | grep -v "schema-meta"); do
176+
echo "corrupt the log file $filename"
177+
filename_temp=$filename"_temp"
178+
echo "corruption" > $filename_temp
179+
cat $filename >> $filename_temp
180+
mv $filename_temp $filename
181+
truncate -s -11 $filename
182+
done
183+
}
184+
185+
# file corruption
186+
file_corruption
187+
export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/utils/set-remaining-attempts-to-one=return(true)"
188+
restore_fail=0
189+
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/full" || restore_fail=1
190+
export GO_FAILPOINTS=""
191+
if [ $restore_fail -ne 1 ]; then
192+
echo 'pitr success on file corruption'
193+
exit 1
194+
fi
195+
196+
# start a new cluster for corruption
197+
restart_services_allowing_huge_index
198+
199+
file_lost() {
200+
echo "lost the whole log files"
201+
for filename in $(find $TEST_DIR/$PREFIX/log -regex ".*\.log" | grep -v "schema-meta"); do
202+
echo "lost the log file $filename"
203+
filename_temp=$filename"_temp"
204+
mv $filename $filename_temp
205+
done
206+
}
207+
>>>>>>> 384f858a6c8 (br/stream: allow pitr to create oversized indices (#58433))
128208

129209
# file lost
130210
mv $filename $filename_bak

0 commit comments

Comments
 (0)