Describe the bug:
Command scan 0 match * count 10000 doesn't return all keys in the DB
Preconditions:
1. Create multi-shard redis enterprise database (Clustering=true, Replication=True, DB has 2 shard (4 with replication))
- Add 6 keys in the DB (via redis-cli, redisinsight cli or redisinsight workbench): set cours:maths:1 blabla set cours:maths:2 blablabla set cours:francais:1 blabla set cours:francais:2 blablabla set cours:francais voila set cours:maths cqfd
To reproduce:
In redis-cli or redisinsight-cli run the command
scan 0 match * count 10000
Expected behavior: All 6 keys are returned
Actual result:
4 keys are returned:
Additional information: OS Windows 10, Use RedisInsight v2 2.0.5 application.
Comment From: oranagra
@elenaNaboko generally, this repo is about the open source Redis, so if you have questions specific to Redis Enterprise you should take it with them.
However, i can save you some time and tell you that the contract with the SCAN command is that the COUNT you provide is just a recommendation for a matter of scale, Redis doesn't attempt to respect that exact count, and can return either less or more than that count in various scenarios, this is true for both OSS redis and Redis Enterprise.
Specifically in your case, each SCAN command is served by one shard and when the keys in one shard are exhausted, it'll return and the next command will be forwarded to the next shard.
Comment From: oranagra
just in case it wasn't clear, in order to scan the database, you need to call the SCAN command repeatedly until it returns a cursor of 0.
and also to be clear, even in OSS redis, without any sharding, there are cases that scan will return with just a few keys, or even 0 keys (and a non-zero cursor), requiring to call SCAN again.
Comment From: elenaNaboko
@oranagra Thanks for the response!