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 1bca504
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/schedule/prepare_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ 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 && float64(store.GetRegionCount())*collectFactor > float64(c.GetNotFromStorageRegionsCntByStore(storeID)) {
return false

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

View check run for this annotation

Codecov / codecov/patch

pkg/schedule/prepare_checker.go#L65

Added line #L65 was 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 1bca504

Please sign in to comment.