From c563a575a174e6ee091d1f941ead74a021ffe7be Mon Sep 17 00:00:00 2001 From: chpfm Date: Tue, 26 Sep 2023 18:57:51 +0300 Subject: [PATCH 1/3] Do not stop collecting mysql statistics because of timeout --- modules/mysql/collect.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/mysql/collect.go b/modules/mysql/collect.go index 774462718..51592bb26 100644 --- a/modules/mysql/collect.go +++ b/modules/mysql/collect.go @@ -68,17 +68,25 @@ func (m *MySQL) collect() (map[string]int64, error) { // TODO: perhaps make a decisions based on privileges? (SHOW GRANTS FOR CURRENT_USER();) if m.doSlaveStatus { if err := m.collectSlaveStatus(mx); err != nil { - m.Errorf("error on collecting slave status: %v", err) - // TODO: shouldn't disable on any error - m.doSlaveStatus = false + if errors.Is(err, context.DeadlineExceeded) { + m.Warning("Deadline exceeded during slave status collection") + } else { + m.Errorf("error on collecting slave status: %v", err) + // TODO: shouldn't disable on any error + m.doSlaveStatus = false + } } } if m.doUserStatistics { if err := m.collectUserStatistics(mx); err != nil { - m.Errorf("error on collecting user statistics: %v", err) - // TODO: shouldn't disable on any error - m.doUserStatistics = false + if errors.Is(err, context.DeadlineExceeded) { + m.Warning("Deadline exceeded during user statistics collection") + } else { + m.Errorf("error on collecting user statistics: %v", err) + // TODO: shouldn't disable on any error + m.doUserStatistics = false + } } } From 637de857239a01ae583b07b21cad949012b6fc3b Mon Sep 17 00:00:00 2001 From: Alexey Cherkasov Date: Tue, 26 Sep 2023 19:30:56 +0300 Subject: [PATCH 2/3] Fix according review --- modules/mysql/collect.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/modules/mysql/collect.go b/modules/mysql/collect.go index 51592bb26..728955206 100644 --- a/modules/mysql/collect.go +++ b/modules/mysql/collect.go @@ -68,25 +68,15 @@ func (m *MySQL) collect() (map[string]int64, error) { // TODO: perhaps make a decisions based on privileges? (SHOW GRANTS FOR CURRENT_USER();) if m.doSlaveStatus { if err := m.collectSlaveStatus(mx); err != nil { - if errors.Is(err, context.DeadlineExceeded) { - m.Warning("Deadline exceeded during slave status collection") - } else { - m.Errorf("error on collecting slave status: %v", err) - // TODO: shouldn't disable on any error - m.doSlaveStatus = false - } + m.Warningf("error on collecting slave status: %v", err) + m.doSlaveStatus = errors.Is(err, context.DeadlineExceeded) } } if m.doUserStatistics { if err := m.collectUserStatistics(mx); err != nil { - if errors.Is(err, context.DeadlineExceeded) { - m.Warning("Deadline exceeded during user statistics collection") - } else { - m.Errorf("error on collecting user statistics: %v", err) - // TODO: shouldn't disable on any error - m.doUserStatistics = false - } + m.Warningf("error on collecting user statistics: %v", err) + m.doUserStatistics = errors.Is(err, context.DeadlineExceeded) } } From d79819ca4bde15423ccdb270cf892fed579e4225 Mon Sep 17 00:00:00 2001 From: Alexey Cherkasov Date: Tue, 26 Sep 2023 19:34:56 +0300 Subject: [PATCH 3/3] Fix lost import --- modules/mysql/collect.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/mysql/collect.go b/modules/mysql/collect.go index 728955206..3ff0882ad 100644 --- a/modules/mysql/collect.go +++ b/modules/mysql/collect.go @@ -5,6 +5,7 @@ package mysql import ( "context" "database/sql" + "errors" "fmt" "strconv" "strings"