Skip to content

Commit c430b45

Browse files
committed
1 parent 8f50ba4 commit c430b45

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

collector/exporter.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,16 @@ func (e *Exporter) scrape(ctx context.Context, ch chan<- prometheus.Metric) {
7979

8080
scrapeTime := time.Now()
8181
if err = e.db.PingContext(ctx); err != nil {
82-
log.Errorln("Error pinging mysqld:", err)
83-
e.metrics.MySQLUp.Set(0)
84-
e.metrics.Error.Set(1)
85-
return
82+
// BUG(arvenil): PMM-2726: When PingContext returns with context deadline exceeded
83+
// the subsequent call will return `bad connection`.
84+
// https://github.com/go-sql-driver/mysql/issues/858
85+
// The PingContext is called second time as a workaround for this issue.
86+
if err = e.db.PingContext(ctx); err != nil {
87+
log.Errorln("Error pinging mysqld:", err)
88+
e.metrics.MySQLUp.Set(0)
89+
e.metrics.Error.Set(1)
90+
return
91+
}
8692
}
8793
e.metrics.MySQLUp.Set(1)
8894

0 commit comments

Comments
 (0)