Skip to content

Commit

Permalink
This is an automated cherry-pick of #54430
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
3pointer authored and ti-chi-bot committed Oct 28, 2024
1 parent cc04dd7 commit cf1d5b3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions br/pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,12 +826,17 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
return errors.Trace(err)
}

<<<<<<< HEAD
var newTS uint64
if client.IsIncremental() {
newTS = restoreTS
}
ddlJobs := restore.FilterDDLJobs(client.GetDDLJobs(), tables)
ddlJobs = restore.FilterDDLJobByRules(ddlJobs, restore.DDLJobBlockListRule)
=======
ddlJobs := FilterDDLJobs(client.GetDDLJobs(), tables)
ddlJobs = FilterDDLJobByRules(ddlJobs, DDLJobBlockListRule)
>>>>>>> 08147e7e258 (Incremental restore: fix the issue that backfill data is not covered by newTS (#54430))

err = client.PreCheckTableTiFlashReplica(ctx, tables, cfg.tiflashRecorder)
if err != nil {
Expand Down Expand Up @@ -882,6 +887,17 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
return errors.Trace(err)
}

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

Expand Down
17 changes: 16 additions & 1 deletion br/tests/br_incremental/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ go-ycsb load mysql -P tests/$TEST_NAME/workload -p mysql.host=$TIDB_IP -p mysql.
row_count_ori_full=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}')

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

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

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

run_sql "create index index_val on ${DB}.t (val);"
run_sql "update ${DB}.t set val = 66 - val;"

# incremental backup
echo "incremental backup start..."
last_backup_ts=$(run_br validate decode --field="end-version" -s "local://$TEST_DIR/$DB/full" | grep -oE "^[0-9]+")
Expand Down Expand Up @@ -69,4 +73,15 @@ for i in $(seq $ROW_COUNT); do
run_sql "INSERT INTO ${DB}.${AUTO_ID_TABLE}(c1) VALUES ($i);"
done

if run_sql "admin check table ${DB}.t;" | grep -q 'inconsistency'; then
echo "TEST: [$TEST_NAME] incremental restore fail on database $DB.t"
exit 1
fi

index_count=$(run_sql "select count(*) from $DB.t use index (index_val);" | awk '/count/{print $2}')
if [ "${index_count}" != "4" ];then
echo "TEST: [$TEST_NAME] index check fail on database $DB.t"
exit 1
fi

run_sql "DROP DATABASE $DB;"

0 comments on commit cf1d5b3

Please sign in to comment.