Merge pull request #793 from go-redis/fix/close-readonly-connections

Close read-only connections
This commit is contained in:
Vladimir Mihailenco 2018-06-18 13:58:19 +03:00 committed by GitHub
commit 4b568cdf1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -19,6 +19,9 @@ func IsRetryableError(err error, retryNetError bool) bool {
if strings.HasPrefix(s, "LOADING ") { if strings.HasPrefix(s, "LOADING ") {
return true return true
} }
if strings.HasPrefix(s, "READONLY ") {
return true
}
if strings.HasPrefix(s, "CLUSTERDOWN ") { if strings.HasPrefix(s, "CLUSTERDOWN ") {
return true return true
} }
@ -38,16 +41,12 @@ func IsNetworkError(err error) bool {
return ok return ok
} }
func IsReadOnlyError(err error) bool {
return strings.HasPrefix(err.Error(), "READONLY ")
}
func IsBadConn(err error, allowTimeout bool) bool { func IsBadConn(err error, allowTimeout bool) bool {
if err == nil { if err == nil {
return false return false
} }
if IsRedisError(err) { if IsRedisError(err) {
return false return strings.HasPrefix(err.Error(), "READONLY ")
} }
if allowTimeout { if allowTimeout {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() { if netErr, ok := err.(net.Error); ok && netErr.Timeout() {