Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix the wrong store monitor #5404

Merged
merged 3 commits into from Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions server/core/store.go
Expand Up @@ -29,10 +29,9 @@ import (

const (
// Interval to save store meta (including heartbeat ts) to etcd.
storePersistInterval = 5 * time.Minute
initialMaxRegionCounts = 30 // exclude storage Threshold Filter when region less than 30
initialMinSpace = 8 * units.GiB // 2^33=8GB
slowStoreThreshold = 80
storePersistInterval = 5 * time.Minute
initialMinSpace = 8 * units.GiB // 2^33=8GB
slowStoreThreshold = 80

// EngineKey is the label key used to indicate engine.
EngineKey = "engine"
Expand Down Expand Up @@ -425,13 +424,14 @@ func (s *StoreInfo) AvailableRatio() float64 {
}

// IsLowSpace checks if the store is lack of space. Not check if region count less
// than initialMaxRegionCounts and available space more than initialMinSpace
// than InitClusterRegionThreshold and available space more than initialMinSpace
func (s *StoreInfo) IsLowSpace(lowSpaceRatio float64) bool {
if s.GetStoreStats() == nil {
return false
}
// issue #3444
if s.regionCount < initialMaxRegionCounts && s.GetAvailable() > initialMinSpace {
// See https://github.com/tikv/pd/issues/3444 and https://github.com/tikv/pd/issues/5391
// TODO: we need find a better way to get the init region number when starting a new cluster.
if s.regionCount < InitClusterRegionThreshold && s.GetAvailable() > initialMinSpace {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe using the start time is better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO here since using start time could also be inaccurate.

return false
}
return s.AvailableRatio() < 1-lowSpaceRatio
Expand Down
2 changes: 1 addition & 1 deletion server/core/store_test.go
Expand Up @@ -135,7 +135,7 @@ func TestLowSpaceRatio(t *testing.T) {
store.rawStats.Available = store.rawStats.Capacity >> 3

re.False(store.IsLowSpace(0.8))
store.regionCount = 31
store.regionCount = 51
re.True(store.IsLowSpace(0.8))
store.rawStats.Available = store.rawStats.Capacity >> 2
re.False(store.IsLowSpace(0.8))
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/checker/replica_checker_test.go
Expand Up @@ -470,7 +470,7 @@ func (suite *replicaCheckerTestSuite) TestStorageThreshold() {
tc.UpdateStorageRatio(2, 0.1, 0.9)
tc.UpdateStoreRegionSize(2, 100*units.MiB)
tc.AddLabelsStore(3, 1, map[string]string{"zone": "z2"})
tc.AddLabelsStore(4, 31, map[string]string{"zone": "z3"})
tc.AddLabelsStore(4, 51, map[string]string{"zone": "z3"})

tc.AddLeaderRegion(1, 1, 2, 3)
region := tc.GetRegion(1)
Expand Down