diff --git a/metrics/grafana/pd.json b/metrics/grafana/pd.json index 3909dc670c6..f07f4a30584 100644 --- a/metrics/grafana/pd.json +++ b/metrics/grafana/pd.json @@ -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, @@ -5260,7 +5365,7 @@ "h": 7, "w": 12, "x": 12, - "y": 31 + "y": 38 }, "id": 1445, "legend": { @@ -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": { @@ -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}}", @@ -5504,7 +5610,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Selector events", + "title": "Selector write events", "tooltip": { "shared": true, "sort": 0, @@ -5656,7 +5762,7 @@ "h": 7, "w": 12, "x": 12, - "y": 45 + "y": 52 }, "id": 148, "legend": { @@ -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, @@ -11964,7 +12166,7 @@ "x": 12, "y": 48 }, - "id": 1455, + "id": 1467, "interval": "", "options": { "displayMode": "lcd", diff --git a/pkg/mcs/discovery/discover.go b/pkg/mcs/discovery/discover.go index 6d939fde540..00e168114b0 100644 --- a/pkg/mcs/discovery/discover.go +++ b/pkg/mcs/discovery/discover.go @@ -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) diff --git a/pkg/mcs/discovery/key_path.go b/pkg/mcs/discovery/key_path.go index d77aa98f3a9..b7bf9d1cac3 100644 --- a/pkg/mcs/discovery/key_path.go +++ b/pkg/mcs/discovery/key_path.go @@ -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") } diff --git a/pkg/tso/keyspace_group_manager_test.go b/pkg/tso/keyspace_group_manager_test.go index 600c46348a4..2ffa802b4f3 100644 --- a/pkg/tso/keyspace_group_manager_test.go +++ b/pkg/tso/keyspace_group_manager_test.go @@ -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 @@ -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() diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index bd33d873750..f0c7d10cdf0 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -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()) } diff --git a/server/config/config.go b/server/config/config.go index 31777cefa21..5bda5bdc9f9 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -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"` @@ -746,7 +738,6 @@ const ( defaultHotRegionCacheHitsThreshold = 3 defaultSchedulerMaxWaitingOperator = 5 defaultLeaderSchedulePolicy = "count" - defaultStoreLimitMode = "manual" defaultEnableJointConsensus = true defaultEnableTiKVSplitRegion = true defaultEnableCrossTableMerge = true @@ -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) } diff --git a/server/config/persist_options.go b/server/config/persist_options.go index 8d6d1b6b6bc..d308f6338a2 100644 --- a/server/config/persist_options.go +++ b/server/config/persist_options.go @@ -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 diff --git a/tests/pdctl/config/config_test.go b/tests/pdctl/config/config_test.go index 9634737e18b..5f446158fb7 100644 --- a/tests/pdctl/config/config_test.go +++ b/tests/pdctl/config/config_test.go @@ -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()