Skip to content

Commit 4ff3a85

Browse files
3pointerti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#54430
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 42b624c commit 4ff3a85

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

br/pkg/task/restore.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,17 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
902902
return errors.Trace(err)
903903
}
904904

905+
<<<<<<< HEAD
905906
var newTS uint64
906907
if client.IsIncremental() {
907908
newTS = restoreTS
908909
}
909910
ddlJobs := restore.FilterDDLJobs(client.GetDDLJobs(), tables)
910911
ddlJobs = restore.FilterDDLJobByRules(ddlJobs, restore.DDLJobBlockListRule)
912+
=======
913+
ddlJobs := FilterDDLJobs(client.GetDDLJobs(), tables)
914+
ddlJobs = FilterDDLJobByRules(ddlJobs, DDLJobBlockListRule)
915+
>>>>>>> 08147e7e258 (Incremental restore: fix the issue that backfill data is not covered by newTS (#54430))
911916

912917
err = client.PreCheckTableTiFlashReplica(ctx, tables, cfg.tiflashRecorder)
913918
if err != nil {
@@ -964,6 +969,17 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
964969
return errors.Trace(err)
965970
}
966971

972+
var newTS uint64
973+
if client.IsIncremental() {
974+
// we need to get the new ts after execDDL
975+
// or backfilled data in upstream may not be covered by
976+
// the new ts.
977+
// see https://github.com/pingcap/tidb/issues/54426
978+
newTS, err = restore.GetTSWithRetry(ctx, mgr.GetPDClient())
979+
if err != nil {
980+
return errors.Trace(err)
981+
}
982+
}
967983
// We make bigger errCh so we won't block on multi-part failed.
968984
errCh := make(chan error, 32)
969985

br/tests/br_incremental/run.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ go-ycsb load mysql -P $CUR/workload -p mysql.host=$TIDB_IP -p mysql.port=$TIDB_P
2727
row_count_ori_full=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}')
2828

2929
run_sql "CREATE TABLE IF NOT EXISTS ${DB}.${AUTO_ID_TABLE} (c1 INT);"
30+
run_sql "create table ${DB}.t (pk bigint primary key, val int not null);"
31+
run_sql "insert into ${DB}.t values (1, 11), (2, 22), (3, 33), (4, 44);"
3032

31-
# full backup
3233
echo "full backup start..."
3334
run_br --pd $PD_ADDR backup db -s "local://$TEST_DIR/$DB/full" --db $DB
3435

@@ -38,6 +39,9 @@ for i in $(seq $ROW_COUNT); do
3839
run_sql "INSERT INTO ${DB}.${AUTO_ID_TABLE}(c1) VALUES ($i);"
3940
done
4041

42+
run_sql "create index index_val on ${DB}.t (val);"
43+
run_sql "update ${DB}.t set val = 66 - val;"
44+
4145
# incremental backup
4246
echo "incremental backup start..."
4347
last_backup_ts=$(run_br validate decode --field="end-version" -s "local://$TEST_DIR/$DB/full" | grep -oE "^[0-9]+")
@@ -70,4 +74,15 @@ for i in $(seq $ROW_COUNT); do
7074
run_sql "INSERT INTO ${DB}.${AUTO_ID_TABLE}(c1) VALUES ($i);"
7175
done
7276

77+
if run_sql "admin check table ${DB}.t;" | grep -q 'inconsistency'; then
78+
echo "TEST: [$TEST_NAME] incremental restore fail on database $DB.t"
79+
exit 1
80+
fi
81+
82+
index_count=$(run_sql "select count(*) from $DB.t use index (index_val);" | awk '/count/{print $2}')
83+
if [ "${index_count}" != "4" ];then
84+
echo "TEST: [$TEST_NAME] index check fail on database $DB.t"
85+
exit 1
86+
fi
87+
7388
run_sql "DROP DATABASE $DB;"

0 commit comments

Comments
 (0)