From 9b5e016e573bff239b7293b05a85b8dd8087f2ab Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 5 Jul 2021 09:34:15 +0200 Subject: [PATCH] Also retry driver.ErrBadConn ErrBadConn is returned by a driver to signal that a driver.Conn is in a bad state. We have to retry with these errors as well. --- pkg/icingadb/db.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/icingadb/db.go b/pkg/icingadb/db.go index e36151f6..c4b75d54 100644 --- a/pkg/icingadb/db.go +++ b/pkg/icingadb/db.go @@ -2,6 +2,7 @@ package icingadb import ( "context" + "database/sql/driver" "fmt" "github.com/go-sql-driver/mysql" "github.com/icinga/icingadb/internal" @@ -437,6 +438,10 @@ func (db *DB) Delete(ctx context.Context, entityType contracts.Entity, ids []int } func IsRetryable(err error) bool { + if errors.Is(err, driver.ErrBadConn) { + return true + } + if errors.Is(err, mysql.ErrInvalidConn) { return true }