Unverified Commit 450c88f3 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix BZMPOP gets unblocked by non-key args and returns them (#10764)

This bug was introduced in #9484 (7.0.0).
It result that BZMPOP blocked on non-key arguments.

Like `bzmpop 0 1 myzset min count 10`, this command will additionally
block in these keys (except for the first and the last argument) and can return their values:
- 0: timeout value
- 1: numkeys value
- min: min/max token
- count: count token
parent 843a4cdc
...@@ -4041,7 +4041,7 @@ void blockingGenericZpopCommand(client *c, robj **keys, int numkeys, int where, ...@@ -4041,7 +4041,7 @@ void blockingGenericZpopCommand(client *c, robj **keys, int numkeys, int where,
/* If the keys do not exist we must block */ /* If the keys do not exist we must block */
struct blockPos pos = {where}; struct blockPos pos = {where};
blockForKeys(c,BLOCKED_ZSET,c->argv+1,c->argc-2,count,timeout,NULL,&pos,NULL); blockForKeys(c,BLOCKED_ZSET,keys,numkeys,count,timeout,NULL,&pos,NULL);
} }
// BZPOPMIN key [key ...] timeout // BZPOPMIN key [key ...] timeout
......
...@@ -2065,6 +2065,33 @@ start_server {tags {"zset"}} { ...@@ -2065,6 +2065,33 @@ start_server {tags {"zset"}} {
close_replication_stream $repl close_replication_stream $repl
} {} {needs:repl} } {} {needs:repl}
test "BZMPOP should not blocks on non key arguments - #10762" {
set rd1 [redis_deferring_client]
set rd2 [redis_deferring_client]
r del myzset myzset2 myzset3
$rd1 bzmpop 0 1 myzset min count 10
wait_for_blocked_clients_count 1
$rd2 bzmpop 0 2 myzset2 myzset3 max count 10
wait_for_blocked_clients_count 2
# These non-key keys will not unblock the clients.
r zadd 0 100 timeout_value
r zadd 1 200 numkeys_value
r zadd min 300 min_token
r zadd max 400 max_token
r zadd count 500 count_token
r zadd 10 600 count_value
r zadd myzset 1 zset
r zadd myzset3 1 zset3
assert_equal {myzset {{zset 1}}} [$rd1 read]
assert_equal {myzset3 {{zset3 1}}} [$rd2 read]
$rd1 close
$rd2 close
} {0} {cluster:skip}
test {ZSET skiplist order consistency when elements are moved} { test {ZSET skiplist order consistency when elements are moved} {
set original_max [lindex [r config get zset-max-ziplist-entries] 1] set original_max [lindex [r config get zset-max-ziplist-entries] 1]
r config set zset-max-ziplist-entries 0 r config set zset-max-ziplist-entries 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment