Skip to content

Commit def3d2d

Browse files
authored
restore: disable pd follower handle (#60116)
close #60105
1 parent 388c36b commit def3d2d

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

br/pkg/conn/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ go_library(
1818
"//pkg/ddl",
1919
"//pkg/domain",
2020
"//pkg/kv",
21-
"//pkg/sessionctx/vardef",
22-
"//pkg/sessionctx/variable",
2321
"@com_github_docker_go_units//:go-units",
2422
"@com_github_opentracing_opentracing_go//:opentracing-go",
2523
"@com_github_pingcap_errors//:errors",

br/pkg/conn/conn.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import (
3232
"github.com/pingcap/tidb/pkg/ddl"
3333
"github.com/pingcap/tidb/pkg/domain"
3434
"github.com/pingcap/tidb/pkg/kv"
35-
"github.com/pingcap/tidb/pkg/sessionctx/vardef"
36-
"github.com/pingcap/tidb/pkg/sessionctx/variable"
3735
"github.com/tikv/client-go/v2/oracle"
3836
"github.com/tikv/client-go/v2/tikv"
3937
"github.com/tikv/client-go/v2/txnkv/txnlock"
@@ -231,16 +229,6 @@ func NewMgr(
231229
}
232230
}
233231

234-
if err = g.UseOneShotSession(storage, !needDomain, func(se glue.Session) error {
235-
enableFollowerHandleRegion, err := se.GetGlobalSysVar(vardef.PDEnableFollowerHandleRegion)
236-
if err != nil {
237-
return err
238-
}
239-
return controller.SetFollowerHandle(variable.TiDBOptOn(enableFollowerHandleRegion))
240-
}); err != nil {
241-
return nil, errors.Trace(err)
242-
}
243-
244232
mgr := &Mgr{
245233
PdController: controller,
246234
storage: storage,

br/pkg/task/restore.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,14 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
836836
if err != nil {
837837
log.Warn("failed to remove checkpoint data for compacted restore", zap.Error(err))
838838
}
839-
err = cfg.snapshotCheckpointMetaManager.RemoveCheckpointData(c)
840-
if err != nil {
841-
log.Warn("failed to remove checkpoint data for snapshot restore", zap.Error(err))
839+
// Skip removing snapshot checkpoint data if this is a pure log restore
840+
// (i.e. restoring only from log backup without a base snapshot backup),
841+
// since snapshotCheckpointMetaManager would be nil in that case
842+
if cfg.snapshotCheckpointMetaManager != nil {
843+
err = cfg.snapshotCheckpointMetaManager.RemoveCheckpointData(c)
844+
if err != nil {
845+
log.Warn("failed to remove checkpoint data for snapshot restore", zap.Error(err))
846+
}
842847
}
843848
} else {
844849
err = cfg.snapshotCheckpointMetaManager.RemoveCheckpointData(c)

br/tests/br_full_ddl/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ fi
136136

137137
# when we have backup stats during backup, we cannot close domain during one shot session.
138138
# so we can check the log count of `one shot domain closed`.
139-
# we will call UseOneShotSession twice to get the value global variable.
139+
# we will call UseOneShotSession once to get the value global variable.
140140
one_shot_session_count=$(cat $LOG | grep "one shot session closed" | wc -l | xargs)
141141
one_shot_domain_count=$(cat $LOG | grep "one shot domain closed" | wc -l | xargs)
142-
if [ "${one_shot_session_count}" -ne "2" ] || [ "$one_shot_domain_count" -ne "0" ];then
142+
if [ "${one_shot_session_count}" -ne "1" ] || [ "$one_shot_domain_count" -ne "0" ];then
143143
echo "TEST: [$TEST_NAME] fail on one shot session check, $one_shot_session_count, $one_shot_domain_count"
144144
exit 1
145145
fi

br/tests/br_incremental_ddl/run.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB/full" --db $DB -t $T
4141

4242
# when we backup, we should close domain in one shot session.
4343
# so we can check the log count of `one shot domain closed` to be 2.
44-
# we will call UseOneShotSession twice to get the value global variable.
44+
# we will call UseOneShotSession once to get the value global variable.
4545
one_shot_session_count=$(cat $LOG | grep "one shot session closed" | wc -l | xargs)
4646
one_shot_domain_count=$(cat $LOG | grep "one shot domain closed" | wc -l | xargs)
47-
if [ "${one_shot_session_count}" -ne "2" ] || [ "$one_shot_domain_count" -ne "2" ];then
47+
if [ "${one_shot_session_count}" -ne "1" ] || [ "$one_shot_domain_count" -ne "1" ];then
4848
echo "TEST: [$TEST_NAME] fail on one shot session check during backup, $one_shot_session_count, $one_shot_domain_count"
4949
exit 1
5050
fi
@@ -74,13 +74,13 @@ last_backup_ts=$(run_br validate decode --field="end-version" -s "local://$TEST_
7474
run_br --pd $PD_ADDR backup db -s "local://$TEST_DIR/$DB/inc" --db $DB --lastbackupts $last_backup_ts --log-file $LOG
7575

7676
# when we doing incremental backup, we should close domain in one shot session.
77-
# so we can check the log count of `one shot domain closed` to be 3.
78-
# we will call UseOneShotSession three times
79-
# 1. to get the value global variable twice.
77+
# so we can check the log count of `one shot domain closed` to be 2.
78+
# we will call UseOneShotSession two times
79+
# 1. to get the value global variable once.
8080
# 2. to get all ddl jobs with session.
8181
one_shot_session_count=$(cat $LOG | grep "one shot session closed" | wc -l | xargs)
8282
one_shot_domain_count=$(cat $LOG | grep "one shot domain closed" | wc -l | xargs)
83-
if [ "${one_shot_session_count}" -ne "3" ] || [ "$one_shot_domain_count" -ne "3" ];then
83+
if [ "${one_shot_session_count}" -ne "2" ] || [ "$one_shot_domain_count" -ne "2" ];then
8484
echo "TEST: [$TEST_NAME] fail on one shot session check during inc backup, $one_shot_session_count, $one_shot_domain_count"
8585
exit 1
8686
fi

0 commit comments

Comments
 (0)