Skip to content

Commit a4db8b6

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 70313bb commit a4db8b6

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
@@ -645,12 +645,17 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
645645
return errors.Trace(err)
646646
}
647647

648+
<<<<<<< HEAD
648649
var newTS uint64
649650
if client.IsIncremental() {
650651
newTS = restoreTS
651652
}
652653
ddlJobs := restore.FilterDDLJobs(client.GetDDLJobs(), tables)
653654
ddlJobs = restore.FilterDDLJobByRules(ddlJobs, restore.DDLJobBlockListRule)
655+
=======
656+
ddlJobs := FilterDDLJobs(client.GetDDLJobs(), tables)
657+
ddlJobs = FilterDDLJobByRules(ddlJobs, DDLJobBlockListRule)
658+
>>>>>>> 08147e7e258 (Incremental restore: fix the issue that backfill data is not covered by newTS (#54430))
654659

655660
err = client.PreCheckTableTiFlashReplica(ctx, tables, cfg.tiflashRecorder)
656661
if err != nil {
@@ -704,6 +709,17 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
704709
}
705710
}
706711

712+
var newTS uint64
713+
if client.IsIncremental() {
714+
// we need to get the new ts after execDDL
715+
// or backfilled data in upstream may not be covered by
716+
// the new ts.
717+
// see https://github.com/pingcap/tidb/issues/54426
718+
newTS, err = restore.GetTSWithRetry(ctx, mgr.GetPDClient())
719+
if err != nil {
720+
return errors.Trace(err)
721+
}
722+
}
707723
// We make bigger errCh so we won't block on multi-part failed.
708724
errCh := make(chan error, 32)
709725

br/tests/br_incremental/run.sh

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

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

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

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

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

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

0 commit comments

Comments
 (0)