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

tikv, server: turn on grpc channelz to help diagnosis and add wait conn establish metric #16263

Merged
merged 4 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 100 additions & 6 deletions metrics/grafana/tidb.json
Original file line number Diff line number Diff line change
Expand Up @@ -11711,7 +11711,7 @@
"dashLength": 10,
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"description": "kv storage batch processing unvailable durations",
"description": "kv storage batch client wait new connection establish duration",
"editable": true,
"error": false,
"fill": 1,
Expand All @@ -11722,7 +11722,7 @@
"x": 16,
"y": 16
},
"id": 180,
"id": 204,
"legend": {
"alignAsTable": true,
"avg": false,
Expand All @@ -11748,7 +11748,7 @@
"steppedLine": false,
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(tidb_tikvclient_batch_client_unavailable_seconds_bucket[1m])) by (le, instance))",
"expr": "histogram_quantile(0.9999, sum(rate(tidb_tikvclient_batch_client_wait_connection_establish_bucket[1m])) by (le, instance))",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{instance}}",
Expand All @@ -11760,7 +11760,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Batch Client Unavailable Duration 95",
"title": "Wait Connection Establish Duration",
"tooltip": {
"msResolution": false,
"shared": true,
Expand Down Expand Up @@ -11883,14 +11883,108 @@
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"description": "kv storage batch processing unvailable durations",
"editable": true,
"error": false,
"fill": 1,
"grid": {},
"gridPos": {
"h": 7,
"w": 8,
"x": 16,
"y": 23
},
"id": 180,
"legend": {
"alignAsTable": true,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "null as zero",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(tidb_tikvclient_batch_client_unavailable_seconds_bucket[1m])) by (le, instance))",
"format": "time_series",
"hide": false,
"intervalFactor": 2,
"legendFormat": "{{instance}}",
"refId": "A",
"step": 10
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Batch Client Unavailable Duration 95",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "s",
"label": null,
"logBase": 1,
"max": null,
"min": "0",
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"title": "Batch Client",
"type": "row"
}
],
"refresh": "30s",
"schemaVersion": 18,
"schemaVersion": 20,
"style": "dark",
"tags": [],
"templating": {
Expand Down Expand Up @@ -11929,4 +12023,4 @@
"title": "Test-Cluster-TiDB",
"uid": "000000011",
"version": 3
}
}
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func RegisterMetrics() {
prometheus.MustRegister(TiKVPendingBatchRequests)
prometheus.MustRegister(TiKVBatchWaitDuration)
prometheus.MustRegister(TiKVBatchClientUnavailable)
prometheus.MustRegister(TiKVBatchClientWaitEstablish)
prometheus.MustRegister(TiKVRangeTaskStats)
prometheus.MustRegister(TiKVRangeTaskPushDuration)
prometheus.MustRegister(HandleSchemaValidate)
Expand Down
8 changes: 8 additions & 0 deletions metrics/tikvclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ var (
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1000s
Help: "batch client unavailable",
})
TiKVBatchClientWaitEstablish = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "tikvclient",
Name: "batch_client_wait_connection_establish",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1000s
Help: "batch client wait new connection establish",
})

TiKVRangeTaskStats = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Expand Down
2 changes: 2 additions & 0 deletions server/http_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/soheilhy/cmux"
"github.com/tiancaiamao/appdash/traceapp"
"go.uber.org/zap"
"google.golang.org/grpc/channelz/service"
static "sourcegraph.com/sourcegraph/appdash-data"
)

Expand Down Expand Up @@ -305,6 +306,7 @@ func (s *Server) startStatusServerAndRPCServer(serverMux *http.ServeMux) {

s.statusServer = &http.Server{Addr: s.statusAddr, Handler: CorsHandler{handler: serverMux, cfg: s.cfg}}
s.grpcServer = NewRPCServer(s.cfg, s.dom, s)
service.RegisterChannelzServiceToServer(s.grpcServer)

go util.WithRecovery(func() {
err := s.grpcServer.Serve(grpcL)
Expand Down
7 changes: 7 additions & 0 deletions store/tikv/client_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ func (c *batchCommandsClient) failPendingRequests(err error) {
}

func (c *batchCommandsClient) waitConnReady() (err error) {
if c.conn.GetState() == connectivity.Ready {
return
}
start := time.Now()
defer func() {
metrics.TiKVBatchClientWaitEstablish.Observe(time.Since(start).Seconds())
}()
dialCtx, cancel := context.WithTimeout(context.Background(), dialTimeout)
for {
s := c.conn.GetState()
Expand Down