Fix ZRANGESTORE crash when zset_max_listpack_entries is 0 (#10767)
When `zrangestore` is called container destination object is created. Before this PR we used to create a listpack based object even if `zset-max-ziplist-entries` or equivalent`zset-max-listpack-entries` was set to 0. This triggered immediate conversion of the listpack into a skiplist in `zrangestore`, which hits an assertion resulting in an engine crash. Added a TCL test that reproduces this issue.
This commit is contained in:
parent
2a099d49d4
commit
6461f09f43
@ -1186,9 +1186,10 @@ void zsetConvert(robj *zobj, int encoding) {
|
||||
zs->zsl = zslCreate();
|
||||
|
||||
eptr = lpSeek(zl,0);
|
||||
serverAssertWithInfo(NULL,zobj,eptr != NULL);
|
||||
sptr = lpNext(zl,eptr);
|
||||
serverAssertWithInfo(NULL,zobj,sptr != NULL);
|
||||
if (eptr != NULL) {
|
||||
sptr = lpNext(zl,eptr);
|
||||
serverAssertWithInfo(NULL,zobj,sptr != NULL);
|
||||
}
|
||||
|
||||
while (eptr != NULL) {
|
||||
score = zzlGetScore(sptr);
|
||||
|
@ -2208,6 +2208,15 @@ start_server {tags {"zset"}} {
|
||||
assert_match "*syntax*" $err
|
||||
}
|
||||
|
||||
test {ZRANGESTORE with zset-max-listpack-entries 0 dst key should use skiplist encoding} {
|
||||
set original_max [lindex [r config get zset-max-listpack-entries] 1]
|
||||
r config set zset-max-listpack-entries 0
|
||||
r del z1{t} z2{t}
|
||||
r zadd z1{t} 1 a
|
||||
assert_equal 1 [r zrangestore z2{t} z1{t} 0 -1]
|
||||
r config set zset-max-listpack-entries $original_max
|
||||
}
|
||||
|
||||
test {ZRANGE invalid syntax} {
|
||||
catch {r zrange z1{t} 0 -1 limit 1 2} err
|
||||
assert_match "*syntax*" $err
|
||||
|
Loading…
x
Reference in New Issue
Block a user