diff --git a/ChangeLog b/ChangeLog index 11b15a2..0785933 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ 2019-06-07 Alibaba Cloud. * VERSION: 1.6.6 * cherry-pick merge v1.4.4 - * + * BUGFIX: delete single command failed when filter key given. 2019-06-06 Alibaba Cloud. * VERSION: 1.6.5 * IMPROVE: run rump in parallel to support several db nodes behind proxy. diff --git a/src/redis-shake/command/redis-command.go b/src/redis-shake/command/redis-command.go index 2913836..3245eef 100644 --- a/src/redis-shake/command/redis-command.go +++ b/src/redis-shake/command/redis-command.go @@ -17,7 +17,7 @@ var RedisCommands = map[string]redisCommand{ "setex": {nil, 1, 1, 1}, "psetex": {nil, 1, 1, 1}, "append": {nil, 1, 1, 1}, - "del": {nil, 1, -1, 1}, + "del": {nil, 1, 0, 1}, "unlink": {nil, 1, -1, 1}, "setbit": {nil, 1, 1, 1}, "bitfield": {nil, 1, 1, 1}, @@ -86,7 +86,7 @@ var RedisCommands = map[string]redisCommand{ "pfmerge": {nil, 1, -1, 1}, } -func GetMatchKeys(redis_cmd redisCommand, args [][]byte, filterkeys []string) (new_args [][]byte, ret bool) { +func GetMatchKeys(redis_cmd redisCommand, args [][]byte, filterkeys []string) (new_args [][]byte, pass bool) { lastkey := redis_cmd.lastkey - 1 keystep := redis_cmd.keystep @@ -107,10 +107,10 @@ func GetMatchKeys(redis_cmd redisCommand, args [][]byte, filterkeys []string) (n } } - ret = false + pass = false new_args = make([][]byte, number*redis_cmd.keystep+len(args)-lastkey-redis_cmd.keystep) if number > 0 { - ret = true + pass = true for i := 0; i < number; i++ { for j := 0; j < redis_cmd.keystep; j++ { new_args[i*redis_cmd.keystep+j] = args[array[i]+j] @@ -124,5 +124,6 @@ func GetMatchKeys(redis_cmd redisCommand, args [][]byte, filterkeys []string) (n new_args[number*redis_cmd.keystep+j] = args[i] j = j + 1 } + return } diff --git a/src/redis-shake/main/main.go b/src/redis-shake/main/main.go index 500f718..3735ff4 100644 --- a/src/redis-shake/main/main.go +++ b/src/redis-shake/main/main.go @@ -374,7 +374,7 @@ func sanitizeOptions(tp string) error { conf.Options.SenderDelayChannelSize = 32 } - if tp == TypeRestore || tp == TypeSync { + if tp == conf.TypeRestore || tp == conf.TypeSync || tp == conf.TypeRump { // get target redis version and set TargetReplace. for _, address := range conf.Options.TargetAddressList { // single connection even if the target is cluster diff --git a/src/redis-shake/sync.go b/src/redis-shake/sync.go index bf87590..3a95b06 100644 --- a/src/redis-shake/sync.go +++ b/src/redis-shake/sync.go @@ -531,7 +531,7 @@ func (ds *dbSyncer) syncCommand(reader *bufio.Reader, target []string, auth_type id := recvId.Get() // receive id // print debug log of receive reply - log.Debugf("receive reply[%v]: [%v], error: [%v]", id, reply, err) + log.Debugf("receive reply-id[%v]: [%v], error:[%v]", id, reply, err) if conf.Options.Metric == false { continue @@ -623,25 +623,28 @@ func (ds *dbSyncer) syncCommand(reader *bufio.Reader, target []string, auth_type ds.nbypass.Incr() // ds.SyncStat.BypassCmdCount.Incr() metric.GetMetric(ds.id).AddBypassCmdCount(1) + log.Debugf("dbSyncer[%v] ignore command[%v]", ds.id, scmd) continue } } - is_filter := false + pass := false if len(conf.Options.FilterKey) != 0 { - ds, ok := command.RedisCommands[scmd] + cmdNode, ok := command.RedisCommands[scmd] if ok && len(argv) > 0 { - new_argv, is_filter = command.GetMatchKeys(ds, argv, conf.Options.FilterKey) + log.Debugf("dbSyncer[%v] filter command[%v]", ds.id, scmd) + new_argv, pass = command.GetMatchKeys(cmdNode, argv, conf.Options.FilterKey) } else { - is_filter = true + pass = true new_argv = argv } } else { - is_filter = true + pass = true new_argv = argv } - if bypass || ignorecmd || !is_filter { + if bypass || ignorecmd || !pass { ds.nbypass.Incr() + log.Debugf("dbSyncer[%v] filter command[%v]", ds.id, scmd) continue } }