Skip to content

Commit

Permalink
Merge branch 'master' into enhance_static
Browse files Browse the repository at this point in the history
  • Loading branch information
HuSharp committed Jul 14, 2023
2 parents 3a6a4e0 + 1dc623a commit 45ce8aa
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 31 deletions.
214 changes: 208 additions & 6 deletions metrics/grafana/pd.json
Original file line number Diff line number Diff line change
Expand Up @@ -5136,6 +5136,111 @@
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"decimals": 2,
"description": "The total keys of hot write on leader Regions for each TiKV instance",
"fill": 0,
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 31
},
"id": 1465,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"hideEmpty": true,
"hideZero": true,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"sort": "current",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "null",
"paceLength": 10,
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "pd_hotspot_status{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", store=~\"$store\", instance=\"$instance\", type=\"total_write_bytes_as_leader\"}",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{address}}-store-{{store}}",
"metric": "pd_hotspot_status",
"refId": "A",
"step": 4
},
{
"exemplar": true,
"expr": "pd_scheduler_hot_peers_summary{type=\"exp-byte-rate-write-leader\"}",
"hide": true,
"interval": "",
"legendFormat": "exp-byte-rate-write-leader-{{store}}",
"refId": "B"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Total written bytes on hot leader Regions",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "ops",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
Expand Down Expand Up @@ -5260,7 +5365,7 @@
"h": 7,
"w": 12,
"x": 12,
"y": 31
"y": 38
},
"id": 1445,
"legend": {
Expand Down Expand Up @@ -5454,12 +5559,13 @@
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"decimals": 0,
"description": "The select events of hot read scheduler",
"fill": 0,
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 38
"y": 45
},
"id": 106,
"legend": {
Expand Down Expand Up @@ -5492,7 +5598,7 @@
"steppedLine": false,
"targets": [
{
"expr": "rate(pd_scheduler_hot_region{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", store=~\"$store\", type=~\".*store.*\"}[1m])",
"expr": "rate(pd_scheduler_hot_region{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", store=~\"$store\", type=~\".*write.*\"}[1m])",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{type}}-{{store}}",
Expand All @@ -5504,7 +5610,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Selector events",
"title": "Selector write events",
"tooltip": {
"shared": true,
"sort": 0,
Expand Down Expand Up @@ -5656,7 +5762,7 @@
"h": 7,
"w": 12,
"x": 12,
"y": 45
"y": 52
},
"id": 148,
"legend": {
Expand Down Expand Up @@ -6737,6 +6843,102 @@
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"decimals": 0,
"description": "The select events of hot read scheduler",
"fill": 0,
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 81
},
"id": 1466,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"hideEmpty": true,
"hideZero": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"sort": "current",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"paceLength": 10,
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "rate(pd_scheduler_hot_region{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", store=~\"$store\", type=~\".*read.*\"}[1m])",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{type}}-{{store}}",
"refId": "A",
"step": 4
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Selector read events",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "none",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"repeat": null,
Expand Down Expand Up @@ -11964,7 +12166,7 @@
"x": 12,
"y": 48
},
"id": 1455,
"id": 1467,
"interval": "",
"options": {
"displayMode": "lcd",
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/discovery/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

// Discover is used to get all the service instances of the specified service name.
func Discover(cli *clientv3.Client, clusterID, serviceName string) ([]string, error) {
key := ServicePath(clusterID, serviceName) + "/"
key := ServicePath(clusterID, serviceName)
endKey := clientv3.GetPrefixRangeEnd(key)

withRange := clientv3.WithRange(endKey)
Expand Down
4 changes: 2 additions & 2 deletions pkg/mcs/discovery/key_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func RegistryPath(clusterID, serviceName, serviceAddr string) string {

// ServicePath returns the path to store microservice addresses.
func ServicePath(clusterID, serviceName string) string {
return strings.Join([]string{utils.MicroserviceRootPath, clusterID, serviceName, registryKey}, "/")
return strings.Join([]string{utils.MicroserviceRootPath, clusterID, serviceName, registryKey, ""}, "/")
}

// TSOPath returns the path to store TSO addresses.
func TSOPath(clusterID uint64) string {
return ServicePath(strconv.FormatUint(clusterID, 10), "tso") + "/"
return ServicePath(strconv.FormatUint(clusterID, 10), "tso")
}
4 changes: 2 additions & 2 deletions pkg/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (suite *keyspaceGroupManagerTestSuite) TestNewKeyspaceGroupManager() {

tsoServiceID := &discovery.ServiceRegistryEntry{ServiceAddr: suite.cfg.AdvertiseListenAddr}
guid := uuid.New().String()
tsoServiceKey := discovery.ServicePath(guid, "tso") + "/"
tsoServiceKey := discovery.ServicePath(guid, "tso")
legacySvcRootPath := path.Join("/pd", guid)
tsoSvcRootPath := path.Join(mcsutils.MicroserviceRootPath, guid, "tso")
electionNamePrefix := "tso-server-" + guid
Expand Down Expand Up @@ -817,7 +817,7 @@ func (suite *keyspaceGroupManagerTestSuite) newKeyspaceGroupManager(
cfg *TestServiceConfig,
) *KeyspaceGroupManager {
tsoServiceID := &discovery.ServiceRegistryEntry{ServiceAddr: cfg.GetAdvertiseListenAddr()}
tsoServiceKey := discovery.ServicePath(uniqueStr, "tso") + "/"
tsoServiceKey := discovery.ServicePath(uniqueStr, "tso")
legacySvcRootPath := path.Join("/pd", uniqueStr)
tsoSvcRootPath := path.Join(mcsutils.MicroserviceRootPath, uniqueStr, "tso")
electionNamePrefix := "kgm-test-" + cfg.GetAdvertiseListenAddr()
Expand Down
2 changes: 1 addition & 1 deletion server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ func (c *RaftCluster) HandleStoreHeartbeat(heartbeat *pdpb.StoreHeartbeatRequest
interval := reportInterval.GetEndTimestamp() - reportInterval.GetStartTimestamp()

// c.limiter is nil before "start" is called
if c.limiter != nil && c.opt.GetStoreLimitMode() == "auto" {
if c.limiter != nil {
c.limiter.Collect(newStore.GetStoreStats())
}

Expand Down
13 changes: 0 additions & 13 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,6 @@ type ScheduleConfig struct {
// Only used to display
SchedulersPayload map[string]interface{} `toml:"schedulers-payload" json:"schedulers-payload"`

// StoreLimitMode can be auto or manual, when set to auto,
// PD tries to change the store limit values according to
// the load state of the cluster dynamically. User can
// overwrite the auto-tuned value by pd-ctl, when the value
// is overwritten, the value is fixed until it is deleted.
// Default: manual
StoreLimitMode string `toml:"store-limit-mode" json:"store-limit-mode"`

// Controls the time interval between write hot regions info into leveldb.
HotRegionsWriteInterval typeutil.Duration `toml:"hot-regions-write-interval" json:"hot-regions-write-interval"`

Expand Down Expand Up @@ -746,7 +738,6 @@ const (
defaultHotRegionCacheHitsThreshold = 3
defaultSchedulerMaxWaitingOperator = 5
defaultLeaderSchedulePolicy = "count"
defaultStoreLimitMode = "manual"
defaultEnableJointConsensus = true
defaultEnableTiKVSplitRegion = true
defaultEnableCrossTableMerge = true
Expand Down Expand Up @@ -806,10 +797,6 @@ func (c *ScheduleConfig) adjust(meta *configutil.ConfigMetaData, reloading bool)
if !meta.IsDefined("leader-schedule-policy") {
configutil.AdjustString(&c.LeaderSchedulePolicy, defaultLeaderSchedulePolicy)
}
if !meta.IsDefined("store-limit-mode") {
configutil.AdjustString(&c.StoreLimitMode, defaultStoreLimitMode)
}

if !meta.IsDefined("store-limit-version") {
configutil.AdjustString(&c.StoreLimitVersion, defaultStoreLimitVersion)
}
Expand Down
5 changes: 0 additions & 5 deletions server/config/persist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,6 @@ func (o *PersistOptions) GetAllStoresLimit() map[uint64]StoreLimitConfig {
return o.GetScheduleConfig().StoreLimit
}

// GetStoreLimitMode returns the limit mode of store.
func (o *PersistOptions) GetStoreLimitMode() string {
return o.GetScheduleConfig().StoreLimitMode
}

// GetStoreLimitVersion returns the limit version of store.
func (o *PersistOptions) GetStoreLimitVersion() string {
return o.GetScheduleConfig().StoreLimitVersion
Expand Down
1 change: 0 additions & 1 deletion tests/pdctl/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func TestConfig(t *testing.T) {
scheduleConfig.EnableMakeUpReplica = false
scheduleConfig.EnableRemoveExtraReplica = false
scheduleConfig.EnableLocationReplacement = false
scheduleConfig.StoreLimitMode = ""
re.Equal(uint64(0), scheduleConfig.MaxMergeRegionKeys)
// The result of config show doesn't be 0.
scheduleConfig.MaxMergeRegionKeys = scheduleConfig.GetMaxMergeRegionKeys()
Expand Down

0 comments on commit 45ce8aa

Please sign in to comment.