print inner error message from redigo driver return message

v4
vinllen 5 years ago
parent c68d2c0e29
commit 40426643ae
  1. 1
      ChangeLog
  2. 19
      src/redis-shake/common/command.go
  3. 9
      src/redis-shake/rump.go

@ -5,6 +5,7 @@
* IMPROVE: adjust RecvChanSize based on `sender.count` or `scan.key_number`
if target redis type is cluster.
* IMPROVE: remove some useless variables in conf like `heartbeat`, `ncpu`.
* IMPROVE: print inner error message from redigo driver return message.
2019-08-09 Alibaba Cloud.
* VERSION: 1.6.16
* BUGFIX: big key in `rump` mode all expired.

@ -10,6 +10,11 @@ import (
"strings"
)
const (
ReplayString = "string"
ReplayInt64s = "int64s"
)
type ClusterNodeInfo struct {
Id string
Address string
@ -173,3 +178,17 @@ func GetAllClusterNode(client redigo.Conn, role string, choose string) ([]string
return result, nil
}
func WrapCommand(tp string, reply interface{}, err error) (interface{}, error) {
if err != nil {
return nil, fmt.Errorf("inner error: %v", err)
}
switch tp {
case ReplayString:
return redigo.Strings(reply, err)
case ReplayInt64s:
return redigo.Int64s(reply, err)
default:
return nil, fmt.Errorf("command type[%v] not support", tp)
}
}

@ -483,19 +483,24 @@ func (dre *dbRumperExecutor) doFetch(db int) error {
log.Debugf("dbRumper[%v] executor[%v] scan key: %v", dre.rumperId, dre.executorId, key)
dre.sourceClient.Send("DUMP", key)
}
dumps, err := redis.Strings(dre.sourceClient.Do(""))
reply, err := dre.sourceClient.Do("")
dumpsRet, err := utils.WrapCommand(utils.ReplayString, reply, err)
if err != nil && err != redis.ErrNil {
return fmt.Errorf("do dump with failed[%v]", err)
}
dumps := dumpsRet.([]string)
// pipeline ttl
for _, key := range keys {
dre.sourceClient.Send("PTTL", key)
}
pttls, err := redis.Int64s(dre.sourceClient.Do(""))
reply, err = dre.sourceClient.Do("")
pttlsRet, err := utils.WrapCommand(utils.ReplayInt64s, reply, err)
if err != nil && err != redis.ErrNil {
return fmt.Errorf("do ttl with failed[%v]", err)
}
pttls := pttlsRet.([]int64)
dre.stat.rCommands.Add(int64(len(keys)))
for i, k := range keys {

Loading…
Cancel
Save