Describe the bug
Running the following test on redis 7.4+ fails. The response from the server is [b"A"]
.
However, if you remove the sort command, the test passes.
def test_zrangebyscore_negative_start_after_sort(r: redis.Redis):
r.zadd("A", {"A": 0.0})
r.zadd("B", {"A": 0.0})
with pytest.raises(redis.ResponseError):
r.sort("B")
assert r.zrangebyscore("B", 0.0, 0.0, start=-1, num=1) == [] # Here
On redis 6.2 the test passes. See here more details which versions it fails/passes
Comment From: sundb
@cunla sort
might change the encoding of sortset, in this case, this sortset was converted from listpack to skiplist.
/* Destructively convert encoded sorted sets for SORT. */
if (sortval->type == OBJ_ZSET)
zsetConvert(sortval, OBJ_ENCODING_SKIPLIST);
seems that https://github.com/redis/redis/pull/12450 brought a bug.
flushdb
zadd a 0.0 A
sort a <- converted to skiplist
# zrangebyscore would return empty before #12450, but now returns the last value.
zrangebyscore a 0.0 0.0 limit -1 1
@cunla do you want to fix it? FYI @oranagra
Comment From: cunla
I can give it a shot
Comment From: yzc-yzc
Hello@cunla ! I've noticed this issue has been stalled for a while. I'm interested in it. Could I pick it up?
Comment From: cunla
Go for it
Comment From: yzc-yzc
Go for it
Thanks!