Skip to content

Commit

Permalink
Merge pull request #59 from Icinga/expected-ReadyForQuery-620
Browse files Browse the repository at this point in the history
Actually retry every database error, including "pq: ..."
  • Loading branch information
yhabteab authored Oct 18, 2024
2 parents c8ef60f + 2eab550 commit 77a5457
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"
"io"
"net"
"strings"
"syscall"
"time"
)
Expand Down Expand Up @@ -197,5 +198,12 @@ func Retryable(err error) bool {
return true
}

// For errors without a five-digit code, github.com/lib/pq uses fmt.Errorf().
// This returns an unexported error type prefixed with "pq: "
// Until this gets changed upstream <https://github.com/lib/pq/issues/1169>, we can only check the error message.
if strings.HasPrefix(err.Error(), "pq: ") {
return true
}

return false
}

0 comments on commit 77a5457

Please sign in to comment.