Skip to content

Commit

Permalink
fix panic caused by nil pointer
Browse files Browse the repository at this point in the history
ref tikv#5638

Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>
  • Loading branch information
ethercflow committed Nov 2, 2022
1 parent 0f706eb commit b01638c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/cluster/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(co.removeScheduler(schedulers.HotRegionName))
re.NoError(co.removeScheduler(schedulers.GrantLeaderName))
re.NoError(co.removeScheduler(schedulers.SplitBucketName))
re.NoError(co.removeScheduler(schedulers.TransferWitnessLeaderName))
// all removed
sches, _, err = storage.LoadAllScheduleConfig()
re.NoError(err)
Expand All @@ -877,7 +878,7 @@ func TestRemoveScheduler(t *testing.T) {
co.run()
re.Empty(co.schedulers)
// the option remains default scheduler
re.Len(co.cluster.opt.GetSchedulers(), 4)
re.Len(co.cluster.opt.GetSchedulers(), 5)
co.stop()
co.wg.Wait()
}
Expand Down
3 changes: 3 additions & 0 deletions server/schedulers/transfer_witness_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func (s *transferLeaderScheduler) scheduleTransferWitnessLeader(name, typ string
}

func NeedTransferWitnessLeader(region *core.RegionInfo) bool {
if region == nil || region.GetLeader() == nil {
return false
}
return region.GetLeader().IsWitness
}

Expand Down

0 comments on commit b01638c

Please sign in to comment.