Skip to content

Commit

Permalink
Merge branch 'master' into hotsche-compatible-cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Aug 13, 2021
2 parents 0017975 + 2b2d886 commit f5eab42
Show file tree
Hide file tree
Showing 36 changed files with 27 additions and 65 deletions.
12 changes: 6 additions & 6 deletions metrics/alertmanager/pd.rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ groups:
- name: alert.rules
rules:
- alert: PD_cluster_offline_tikv_nums
expr: (sum ( pd_cluster_status{type="store_down_count"} ) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
expr: (sum(pd_cluster_status{type="store_down_count"}) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
for: 1m
labels:
env: ENV_LABELS_ENV
level: emergency
expr: (sum ( pd_cluster_status{type="store_down_count"} ) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
expr: (sum(pd_cluster_status{type="store_down_count"}) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
annotations:
description: 'cluster: ENV_LABELS_ENV, instance: {{ $labels.instance }}, values:{{ $value }}'
value: '{{ $value }}'
Expand Down Expand Up @@ -38,24 +38,24 @@ groups:
summary: PD_miss_peer_region_count

- alert: PD_cluster_lost_connect_tikv_nums
expr: (sum ( pd_cluster_status{type="store_disconnected_count"} ) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
expr: (sum(pd_cluster_status{type="store_disconnected_count"}) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
for: 1m
labels:
env: ENV_LABELS_ENV
level: warning
expr: (sum ( pd_cluster_status{type="store_disconnected_count"} ) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
expr: (sum(pd_cluster_status{type="store_disconnected_count"}) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
annotations:
description: 'cluster: ENV_LABELS_ENV, instance: {{ $labels.instance }}, values:{{ $value }}'
value: '{{ $value }}'
summary: PD_cluster_lost_connect_tikv_nums

- alert: PD_cluster_low_space
expr: (sum ( pd_cluster_status{type="store_low_space_count"} ) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
expr: (sum(pd_cluster_status{type="store_low_space_count"}) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
for: 1m
labels:
env: ENV_LABELS_ENV
level: warning
expr: (sum ( pd_cluster_status{type="store_low_space_count"} ) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
expr: (sum(pd_cluster_status{type="store_low_space_count"}) by (instance) > 0) and (sum(etcd_server_is_leader) by (instance) > 0)
annotations:
description: 'cluster: ENV_LABELS_ENV, instance: {{ $labels.instance }}, values:{{ $value }}'
value: '{{ $value }}'
Expand Down
1 change: 0 additions & 1 deletion pkg/apiutil/serverapi/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (h *runtimeServiceValidator) ServeHTTP(w http.ResponseWriter, r *http.Reque

// IsServiceAllowed checks the service through the path.
func IsServiceAllowed(s *server.Server, group server.ServiceGroup) bool {

// for core path
if group.IsCore {
return true
Expand Down
1 change: 0 additions & 1 deletion pkg/btree/btree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func TestBTreeSizeInfo(t *testing.T) {
assertEq(t, "delete max get nil rank", rk, x/3+1)
}
}

}

var btreeDegree = flag.Int("degree", 32, "B-Tree degree")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ttlCacheItem struct {
expire time.Time
}

// ttlCache is a cache that assigns TTL(Time-To-Live) for each items.
// ttlCache is a cache that assigns TTL (Time-To-Live) for each items.
type ttlCache struct {
sync.RWMutex
ctx context.Context
Expand Down
3 changes: 1 addition & 2 deletions pkg/errs/errs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package errs

import (
"bytes"
"fmt"
"strconv"
"strings"
"testing"
Expand All @@ -38,7 +37,7 @@ func newTestingWriter() *testingWriter {
func (w *testingWriter) Write(p []byte) (n int, err error) {
n = len(p)
p = bytes.TrimRight(p, "\n")
m := fmt.Sprintf("%s", p)
m := string(p)
w.messages = append(w.messages, m)
return n, nil
}
Expand Down
1 change: 0 additions & 1 deletion pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ func (mc *Cluster) RemoveScheduler(name string) error {
// If leaderStoreID is zero, the regions would have no leader
func (mc *Cluster) MockRegionInfo(regionID uint64, leaderStoreID uint64,
followerStoreIDs, learnerStoreIDs []uint64, epoch *metapb.RegionEpoch) *core.RegionInfo {

region := &metapb.Region{
Id: regionID,
StartKey: []byte(fmt.Sprintf("%20d", regionID)),
Expand Down
4 changes: 2 additions & 2 deletions pkg/movingaverage/avg_over_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (t *testAvgOverTimeSuite) TestChange(c *C) {
c.Assert(aot.Get(), LessEqual, 1010.)
c.Assert(aot.Get(), GreaterEqual, 990.)

//phase 2: 500
// phase 2: 500
for i := 0; i < 5; i++ {
aot.Add(500, time.Second)
}
Expand All @@ -62,7 +62,7 @@ func (t *testAvgOverTimeSuite) TestChange(c *C) {
aot.Add(500, time.Second)
}

//phase 3: 100
// phase 3: 100
for i := 0; i < 5; i++ {
aot.Add(100, time.Second)
}
Expand Down
2 changes: 0 additions & 2 deletions plugin/scheduler_example/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func init() {
}
conf.StoreIDWitRanges[id] = ranges
return nil

}
})

Expand Down Expand Up @@ -231,7 +230,6 @@ func (s *evictLeaderScheduler) Schedule(cluster opt.Cluster) []*operator.Operato
if err != nil {
log.Debug("fail to create evict leader operator", errs.ZapError(err))
continue

}
op.SetPriorityLevel(core.HighPriority)
ops = append(ops, op)
Expand Down
1 change: 0 additions & 1 deletion server/api/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func (filter *storesLabelFilter) filter(stores []*metapb.Store) []*metapb.Store
break
}
}

}
return ret
}
2 changes: 0 additions & 2 deletions server/api/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func (s *testRuleSuite) TestSet(c *C) {
_, ok := testcase.popKeyRange[k]
c.Assert(ok, Equals, true)
}

} else {
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, testcase.response)
Expand Down Expand Up @@ -797,7 +796,6 @@ func (s *testRuleSuite) TestBundle(c *C) {
compareBundle(c, bundles[0], b1)
compareBundle(c, bundles[1], b4)
compareBundle(c, bundles[2], b5)

}

func (s *testRuleSuite) TestBundleBadRequest(c *C) {
Expand Down
1 change: 0 additions & 1 deletion server/api/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ func (s *testScheduleSuite) TestAPI(c *C) {
}
s.deleteScheduler(createdName, c)
}

}

func (s *testScheduleSuite) TestDisable(c *C) {
Expand Down
1 change: 0 additions & 1 deletion server/api/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func (s *testStoreSuite) TestStoresList(c *C) {
err = readJSON(testDialClient, url, info)
c.Assert(err, IsNil)
checkStoresInfo(c, info.Stores, s.stores[2:3])

}

func (s *testStoreSuite) TestStoreGet(c *C) {
Expand Down
1 change: 0 additions & 1 deletion server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ func (s *testClusterInfoSuite) TestUpStore(c *C) {
// store 4 not exist
err = cluster.UpStore(4)
c.Assert(errors.ErrorEqual(err, errs.ErrStoreNotFound.FastGenByArgs(4)), IsTrue)

}

func (s *testClusterInfoSuite) TestDeleteStoreUpdatesClusterVersion(c *C) {
Expand Down
2 changes: 0 additions & 2 deletions server/cluster/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ func collectHotMetrics(s *scheduleController, stores []*core.StoreInfo, typ stri
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "total_"+kind+"_keys_as_leader").Set(0)
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "total_"+kind+"_query_as_leader").Set(0)
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "hot_"+kind+"_region_as_leader").Set(0)

}

stat, ok = status.AsPeer[storeID]
Expand All @@ -579,7 +578,6 @@ func collectHotMetrics(s *scheduleController, stores []*core.StoreInfo, typ stri
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "total_"+kind+"_keys_as_peer").Set(0)
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "total_"+kind+"_query_as_peer").Set(0)
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "hot_"+kind+"_region_as_peer").Set(0)

}
}
}
Expand Down
1 change: 0 additions & 1 deletion server/cluster/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ func (s *testCoordinatorSuite) TestCheckerIsBusy(c *C) {
c.Assert(co.opController.AddWaitingOperator(ops...), Equals, len(ops))
}
}

}
}
s.checkRegion(c, tc, co, num, 0)
Expand Down
4 changes: 2 additions & 2 deletions server/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,15 +1004,15 @@ func (r *RegionsInfo) RandLearnerRegions(storeID uint64, ranges []KeyRange, n in
return r.learners[storeID].RandomRegions(n, ranges)
}

// GetLeader returns leader RegionInfo by storeID and regionID(now only used in test)
// GetLeader returns leader RegionInfo by storeID and regionID (now only used in test)
func (r *RegionsInfo) GetLeader(storeID uint64, region *RegionInfo) *RegionInfo {
if leaders, ok := r.leaders[storeID]; ok {
return leaders.find(region).region
}
return nil
}

// GetFollower returns follower RegionInfo by storeID and regionID(now only used in test)
// GetFollower returns follower RegionInfo by storeID and regionID (now only used in test)
func (r *RegionsInfo) GetFollower(storeID uint64, region *RegionInfo) *RegionInfo {
if followers, ok := r.followers[storeID]; ok {
return followers.find(region).region
Expand Down
1 change: 0 additions & 1 deletion server/region_syncer/history_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func (h *historyBuffer) distanceToTail(pos int) int {
return h.tail + h.size - pos
}
return h.tail - pos

}

func (h *historyBuffer) nextIndex() uint64 {
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/checker/priority_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewRegionEntry(regionID uint64) *RegionPriorityEntry {

// Check check region's replicas, it will put into priority queue if the region lack of replicas.
func (p *PriorityChecker) Check(region *core.RegionInfo) (fit *placement.RegionFit) {
makeupCount := 0
var makeupCount int
if p.opts.IsPlacementRulesEnabled() {
makeupCount, fit = p.checkRegionInPlacementRule(region)
} else {
Expand Down
4 changes: 2 additions & 2 deletions server/schedule/checker/priority_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func checkPriorityRegionTest(pc *PriorityChecker, tc *mockcluster.Cluster, c *C)
// the region will not rerun after it checks
c.Assert(0, Equals, len(pc.GetPriorityRegions()))

//case3: check region-3, it will has high priority
// case3: check region-3, it will has high priority
region = tc.GetRegion(3)
pc.Check(region)
c.Assert(2, Equals, pc.queue.Len())
Expand All @@ -79,7 +79,7 @@ func checkPriorityRegionTest(pc *PriorityChecker, tc *mockcluster.Cluster, c *C)
c.Assert(uint64(3), Equals, ids[0])
c.Assert(uint64(2), Equals, ids[1])

// case3: check region-2 again after it fixup replicas
// case4: check region-2 again after it fixup replicas
tc.AddLeaderRegion(2, 2, 3, 1)
region = tc.GetRegion(2)
pc.Check(region)
Expand Down
4 changes: 2 additions & 2 deletions server/schedule/plugin_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (p *PluginInterface) GetFunction(path string, funcName string) (plugin.Symb
p.pluginMapLock.Lock()
defer p.pluginMapLock.Unlock()
if _, ok := p.pluginMap[path]; !ok {
//open plugin
// open plugin
filePath, err := filepath.Abs(path)
if err != nil {
return nil, errs.ErrFilePathAbs.Wrap(err).FastGenWithCause()
Expand All @@ -54,7 +54,7 @@ func (p *PluginInterface) GetFunction(path string, funcName string) (plugin.Symb
}
p.pluginMap[path] = plugin
}
//get func from plugin
// get func from plugin
f, err := p.pluginMap[path].Lookup(funcName)
if err != nil {
return nil, errs.ErrLookupPluginFunc.Wrap(err).FastGenWithCause()
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/region_scatterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (s *testScatterRegionSuite) scatter(c *C, numStores, numRegions uint64, use
}
}

//Each store should have the same number of peers.
// Each store should have the same number of peers.
for _, count := range countPeers {
c.Assert(float64(count), LessEqual, 1.1*float64(numRegions*3)/float64(numStores))
c.Assert(float64(count), GreaterEqual, 0.9*float64(numRegions*3)/float64(numStores))
Expand Down
8 changes: 4 additions & 4 deletions server/schedulers/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ func (s *testBalanceRegionSchedulerSuite) TestBalance(c *C) {

func (s *testBalanceRegionSchedulerSuite) TestReplicas3(c *C) {
opt := config.NewTestOptions()
//TODO: enable placementrules
// TODO: enable placementrules
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetMaxReplicas(3)
Expand Down Expand Up @@ -714,7 +714,7 @@ func (s *testBalanceRegionSchedulerSuite) checkReplica3(c *C, tc *mockcluster.Cl

func (s *testBalanceRegionSchedulerSuite) TestReplicas5(c *C) {
opt := config.NewTestOptions()
//TODO: enable placementrules
// TODO: enable placementrules
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetMaxReplicas(5)
Expand Down Expand Up @@ -902,7 +902,7 @@ func (s *testBalanceRegionSchedulerSuite) TestReplacePendingRegion(c *C) {
func (s *testBalanceRegionSchedulerSuite) TestOpInfluence(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
//TODO: enable placementrules
// TODO: enable placementrules
tc.SetEnablePlacementRules(false)
tc.DisableFeature(versioninfo.JointConsensus)
stream := hbstream.NewTestHeartbeatStreams(s.ctx, tc.ID, tc, false /* no need to run */)
Expand Down Expand Up @@ -1023,7 +1023,7 @@ func (s *testRandomMergeSchedulerSuite) TestMerge(c *C) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
opt := config.NewTestOptions()
//TODO: enable palcementrules
// TODO: enable palcementrules
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetMergeScheduleLimit(1)
Expand Down
1 change: 0 additions & 1 deletion server/schedulers/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func init() {
}
conf.StoreIDWithRanges[id] = ranges
return nil

}
})

Expand Down
1 change: 0 additions & 1 deletion server/schedulers/hot_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ func (h *hotScheduler) balanceHotReadRegions(cluster opt.Cluster) []*operator.Op
if peerSolver.tryAddPendingInfluence() {
return peerOps
}

} else {
if peerSolver.tryAddPendingInfluence() {
return peerOps
Expand Down
2 changes: 1 addition & 1 deletion server/schedulers/hot_region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (s *testHotWriteRegionSchedulerSuite) TestByteRateOnlyWithTiFlash(c *C) {
c.Assert(err, IsNil)
hb := sche.(*hotScheduler)

// Add TiKV stores 1, 2, 3, 4, 5, 6, 7(Down) with region counts 3, 3, 2, 2, 0, 0, 0.
// Add TiKV stores 1, 2, 3, 4, 5, 6, 7 (Down) with region counts 3, 3, 2, 2, 0, 0, 0.
// Add TiFlash stores 8, 9, 10, 11 with region counts 3, 1, 1, 0.
storeCount := uint64(11)
aliveTiKVStartID := uint64(1)
Expand Down
2 changes: 1 addition & 1 deletion server/statistics/hot_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type HotPeerStat struct {
needDelete bool
isLeader bool
isNew bool
//TODO: remove it when we send peer stat by store info
// TODO: remove it when we send peer stat by store info
justTransferLeader bool
interval uint64
thresholds []float64
Expand Down
2 changes: 1 addition & 1 deletion server/statistics/topn.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (hp *indexedHeap) Get(id uint64) TopNItem {
return nil
}
item := hp.items[idx]
return item.(TopNItem)
return item
}

// GetAll returns all the items.
Expand Down
Loading

0 comments on commit f5eab42

Please sign in to comment.