Closed jan-domozilov closed 10 months ago
Redis uses an unsigned 64 bit long value whereas our implementation uses the signed variant. We need to fix this bug.
@mp911de I'm having a similar problem right now, and if the issue is before the revision, can I fix it and post PR?
Unfortuneately, this change isn't straightforward as the cursor is being used across the ScanCursor
and ScanIteration
types including method signatures. We can make it work, but it will require a wider scope of changes.
Bug Report
Current Behavior
I am using AWS ElastiCache (Redis), the brand new serverless version of it (https://aws.amazon.com/blogs/aws/amazon-elasticache-serverless-for-redis-and-memcached-now-generally-available/). This is the first time I am using AWS ElastiCache at all, so I am not sure whether this is new Serverless ElasticCache specific or maybe ElastiCache related issue in general.
So, I connect to Redis using Lettuce:
and I create RedisTemplate like this
All good. I can write and read from Redis.
Then I try to do simple scan like that
Cursor c = redisTemplate.scan(ScanOptions.scanOptions().match(cacheName + "*").build());
And I get an exception
To get confirmation I connect to Redis via redis-cli and
Well, 9286422431637962824 returned by AWS Redis as the cursor is bigger than Long.MAX_VALUE and this is the source of the problem.
There is ScanIteration which expects cursorId to be long
and LettuceScanIteration extends ScanIteration
while io.lettuce.core.ScanCursor treats cursor as String.
Expected behavior/code
Scan should work and not end up in NumberFormatException.
Environment
Summary
Seems like there are 3 options on a table:
1) It is me who is doing something wrong or I am missing something. Am I doing something wrong? 2) It is specifically AWS Redis doing something wrong returning cursor value to be bigger than Long.MAX_VALUE. I googled trying to find some Redis specification stating rules about cursor value - I was not able to find anything. If such exists could you please refer me to it and then I will report to AWS or Redis depending on what specifications state? 3) If there is no such specification (I still expect there should be one I just was not able to find it) then spring-data-redis states cursor should be Long while there is no strict specification for such
As I was not able to find specification about cursor value by Redis and due to the fact that in the end it is spring-data-redis codebase which does Long.parseLong(cursorValueFromRedis) line of code I decided to start by reporting bug first here.
Quick workaround
Could you please suggest a quick workaround if possible?