-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed as not planned
Labels
Description
Scan command in pipeline cause infinite loop
Expected Behavior
Scan command return an iterator, then invoke iterator.Next(ctx) should forward scan cursor.
Current Behavior
block at iterator.Next()
Possible Solution
Steps to Reproduce
ctx := context.Background()
var cmd *redis.ScanCmd
cmds, err := rdb.Pipelined(ctx, func(pipeliner redis.Pipeliner) error {
_ = pipeliner.Scan(ctx, 0, "som:key:*", 1000)
return nil
})
cmd = cmds[0].(*redis.ScanCmd)
if err != nil {
t.Error(cmd.Err())
return
}
var cnt = 1
iter := cmd.Iterator()
var keys []string
for {
val := iter.Val()
if val != "" {
keys = append(keys, val)
}
if !iter.Next(ctx) { // infinite loop here
break
}
if iter.Err() != nil {
t.Error(iter.Err())
return
}
cnt++
}
t.Logf("cnt:%d,result, len(%d):\n%s", cnt, len(keys), strings.Join(keys, "\n"))Context (Environment)
redis/v9