Skip to content

Commit

Permalink
schedule: fix the attempt mechanism (#6825)
Browse files Browse the repository at this point in the history
close #5201

Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx authored Jul 21, 2023
1 parent c9939b6 commit dac6dad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/schedule/checker/priority_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ func (p *PriorityInspector) addOrRemoveRegion(priority int, regionID uint64) {
e := entry.Value.(*RegionPriorityEntry)
e.Attempt++
e.Last = time.Now()
p.queue.Put(priority, e)
} else {
entry := NewRegionEntry(regionID)
p.queue.Put(priority, entry)
}
entry := NewRegionEntry(regionID)
p.queue.Put(priority, entry)
} else {
p.queue.Remove(regionID)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/schedule/checker/priority_inspector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ func checkPriorityRegionTest(re *require.Assertions, pc *PriorityInspector, tc *
pc.Inspect(region)
re.Equal(1, pc.queue.Len())

// case5: inspect region 3 again
region = tc.GetRegion(3)
pc.Inspect(region)
time.Sleep(opt.GetPatrolRegionInterval() * 10)
ids = pc.GetPriorityRegions()
re.Empty(ids)

// recover
tc.AddLeaderRegion(2, 2, 3)
pc.RemovePriorityRegion(uint64(3))
Expand Down

0 comments on commit dac6dad

Please sign in to comment.