AspNetCoreRateLimit icon indicating copy to clipboard operation
AspNetCoreRateLimit copied to clipboard

Redis counter data has changed value between 3.x and 4.x

Open pergardebrink opened this issue 2 years ago • 0 comments

We were trying to upgrade the rate limit package from 3.0.5 to 4.0.1 and hit an issue where it seems like the data format in the value of the counter in redis has changed, causing the redis LUA script to fail with:

StackExchange.Redis.RedisServerException: ERR Error running script (call to f_4dd896389061edf088699e7230bfd52bbea35edd): @user_script:1: ERR value is not a valid float

When we rolled back and the code had been running for a while and apparently succeeded in writing new keys with the new format, it seemed to fail in the other direction as the library in 3.0.5 tried to deserialize the numerical values back to a RateLimitCounter:

Error converting value 4 to type 'System.Nullable`1[AspNetCoreRateLimit.RateLimitCounter]'. Path '', line 1, position 1.

For the future, would it be possible to introduce a versioning setting for keys to use when the data format changes?

I am wondering if there is a simple quick solution to this problem where we could make the counter keys become different to not collide with the old names? Would for example introduce a custom contributor to just add an arbitrary string to make the SHA1 hash change?

pergardebrink avatar Aug 24 '22 08:08 pergardebrink