mirror of https://github.com/go-redis/redis.git
recognise read only error returned from Lua script
This commit is contained in:
parent
af4872cbd0
commit
d1c26e1fe6
11
error.go
11
error.go
|
@ -58,7 +58,7 @@ func shouldRetry(err error, retryTimeout bool) bool {
|
||||||
if strings.HasPrefix(s, "LOADING ") {
|
if strings.HasPrefix(s, "LOADING ") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(s, "READONLY ") {
|
if isReadOnlyError(err) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(s, "CLUSTERDOWN ") {
|
if strings.HasPrefix(s, "CLUSTERDOWN ") {
|
||||||
|
@ -137,7 +137,14 @@ func isLoadingError(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isReadOnlyError(err error) bool {
|
func isReadOnlyError(err error) bool {
|
||||||
return strings.HasPrefix(err.Error(), "READONLY ")
|
redisError := err.Error()
|
||||||
|
if strings.HasPrefix(redisError, "READONLY ") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// For a Lua script that includes a write command, the error string
|
||||||
|
// contains "-READONLY" rather than beginning with "READONLY "
|
||||||
|
return strings.Contains(redisError, "-READONLY")
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMovedSameConnAddr(err error, addr string) bool {
|
func isMovedSameConnAddr(err error, addr string) bool {
|
||||||
|
|
Loading…
Reference in New Issue