kinoute opened a new issue, #1402:
URL: https://github.com/apache/incubator-kvrocks/issues/1402

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-kvrocks/issues) and found no 
similar issues.
   
   
   ### Version
   
   2.3.0
   
   ### Minimal reproduce step
   
   1. Start Kvrocks Docker container:
   
   `docker run -it -p 6666:6666 apache/kvrocks`
   
   2. Populate the database with 200k keys with Python 3.9.13 and the forked 
version of Redis-py available here : https://github.com/hashlookup/redis-py
   
   ```bash
   pip install git+https://github.com/hashlookup/redis-py@master
   ```
   
   ```python3
   import redis
   
   REDIS = redis.Redis(
       host='0.0.0.0',
       port=6666,
       password='',
       db=0,
       )
   
   # Populate Kvrocks with 200 keys
   pipe = REDIS.pipeline()
   
   for i in range(200_000):
       pipe.set(f'dba_{i}', 1)
   
   pipe.execute()
   
   # Test "scan_iter"
   for key in scan_iter('dba_*'):
       print(key)
   
   
   # Test "scan"
   cursor = '0'
   
   while True:
       cursor, keys = REDIS.scan(
           cursor=cursor,
           match='dba_*',
       )
       for key in keys:
           print(key)
   
       if not keys:
           break
   
   ### What did you expect to see?
   
   I expected both commands to iterate through every `dba_*` key.
   
   ### What did you see instead?
   
   Instead, both commands are stuck on the first iteration of default size (10) 
and keep printing the same batch of keys every time.
   
   Exemple with `scan_iter`:
   
   
   ```
   b'dba_0'
   b'dba_1'
   b'dba_10'
   b'dba_100'
   b'dba_1000'
   b'dba_10000'
   b'dba_100000'
   b'dba_100001'
   b'dba_100002'
   b'dba_100003'
   b'dba_100004'
   b'dba_100005'
   b'dba_100006'
   b'dba_100007'
   b'dba_100008'
   b'dba_100009'
   b'dba_10001'
   b'dba_100010'
   b'dba_100011'
   b'dba_100012'
   b'dba_1'
   b'dba_10'
   b'dba_100'
   b'dba_1000'
   b'dba_10000'
   b'dba_100000'
   b'dba_100001'
   b'dba_100002'
   b'dba_100003'
   b'dba_100004'
   b'dba_100005'
   b'dba_100006'
   b'dba_100007'
   b'dba_100008'
   b'dba_100009'
   b'dba_10001'
   b'dba_100010'
   b'dba_100011'
   b'dba_100012'
   b'dba_100013'
   b'dba_1'
   b'dba_10'
   b'dba_100'
   b'dba_1000'
   b'dba_10000'
   b'dba_100000'
   b'dba_100001'
   b'dba_100002'
   b'dba_100003'
   b'dba_100004'
   b'dba_100005'
   b'dba_100006'
   b'dba_100007'
   b'dba_100008'
   b'dba_100009'
   b'dba_10001'
   b'dba_100010'
   b'dba_100011'
   b'dba_100012'
   b'dba_100013'
   ```
   
   etc.
   
   ### Anything Else?
   
   While being inefficient, `keys` doesn't suffer from this problem and return 
every key matching the pattern:
   
   ```python3
   len(REDIS.keys('dba_*'))
   
   200000
   ```
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to