Skip to content

Commit

Permalink
tidb: session retry metrics (pingcap#2419)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and shenli committed Jan 9, 2017
1 parent 962cd0c commit 677a85b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions domain/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ var (
loadSchemaCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "domain",
Subsystem: "server",
Name: "load_schema_total",
Help: "Counter of load schema",
}, []string{"type"})

loadSchemaDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "domain",
Subsystem: "server",
Name: "load_schema_duration",
Help: "Bucketed histogram of processing time (s) in load schema.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
Expand Down
8 changes: 8 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ var (
Name: "schema_lease_error_counter",
Help: "Counter of schema lease error",
}, []string{"type"})
sessionRetry = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_retry",
Help: "Bucketed histogram of session retry count.",
Buckets: prometheus.LinearBuckets(0, 1, 10),
})
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,13 @@ func (s *session) Retry() error {
return errors.Errorf("can not retry select for update statement")
}
s.sessionVars.RetryInfo.Retrying = true
retryCnt := 0
defer func() {
s.sessionVars.RetryInfo.Retrying = false
sessionRetry.Observe(float64(retryCnt))
}()
nh := getHistory(s)
var err error
retryCnt := 0
for {
s.prepareTxnCtx()
s.sessionVars.RetryInfo.ResetOffset()
Expand Down

0 comments on commit 677a85b

Please sign in to comment.