Skip to content

Commit

Permalink
prevent suddenly scheduling
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Jan 16, 2024
1 parent 2a4dbc0 commit b21a599
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/schedule/prepare_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func (checker *prepareChecker) check(c *core.BasicCluster, collectWaitTime ...ti
continue
}
storeID := store.GetID()
// It is used to avoid sudden scheduling when scheduling service is just started.
if len(collectWaitTime) > 0 {
if float64(store.GetRegionCount())*collectFactor > float64(c.GetNotFromStorageRegionsCntByStore(storeID)) {
return false

Check warning on line 66 in pkg/schedule/prepare_checker.go

View check run for this annotation

Codecov / codecov/patch

pkg/schedule/prepare_checker.go#L65-L66

Added lines #L65 - L66 were not covered by tests
}
}
// For each store, the number of active regions should be more than total region of the store * collectFactor
if float64(c.GetStoreRegionCount(storeID))*collectFactor > float64(c.GetNotFromStorageRegionsCntByStore(storeID)) {
return false
Expand Down

0 comments on commit b21a599

Please sign in to comment.