mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
d7d13721d3
If a blocked module client times-out (or disconnects, unblocked by CLIENT command, etc.) we need to call moduleUnblockClient in order to free memory allocated by the module sub-system and blocked-client private data Other changes: Made blockedonkeys.tcl tests a bit more aggressive in order to smoke-out potential memory leaks
121 lines
3.5 KiB
Tcl
121 lines
3.5 KiB
Tcl
set testmodule [file normalize tests/modules/blockonkeys.so]
|
|
|
|
start_server {tags {"modules"}} {
|
|
r module load $testmodule
|
|
|
|
test {Module client blocked on keys (no metadata): No block} {
|
|
r del k
|
|
r fsl.push k 33
|
|
r fsl.push k 34
|
|
r fsl.bpop2 k 0
|
|
} {34 33}
|
|
|
|
test {Module client blocked on keys (no metadata): Timeout} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
r fsl.push k 33
|
|
$rd fsl.bpop2 k 1
|
|
assert_equal {Request timedout} [$rd read]
|
|
}
|
|
|
|
test {Module client blocked on keys (no metadata): Blocked, case 1} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
r fsl.push k 33
|
|
$rd fsl.bpop2 k 0
|
|
r fsl.push k 34
|
|
assert_equal {34 33} [$rd read]
|
|
}
|
|
|
|
test {Module client blocked on keys (no metadata): Blocked, case 2} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
r fsl.push k 33
|
|
r fsl.push k 34
|
|
$rd fsl.bpop2 k 0
|
|
assert_equal {34 33} [$rd read]
|
|
}
|
|
|
|
test {Module client blocked on keys (with metadata): No block} {
|
|
r del k
|
|
r fsl.push k 34
|
|
r fsl.bpopgt k 30 0
|
|
} {34}
|
|
|
|
test {Module client blocked on keys (with metadata): Timeout} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd client id
|
|
set cid [$rd read]
|
|
r fsl.push k 33
|
|
$rd fsl.bpopgt k 35 1
|
|
assert_equal {Request timedout} [$rd read]
|
|
r client kill id $cid ;# try to smoke-out client-related memory leak
|
|
}
|
|
|
|
test {Module client blocked on keys (with metadata): Blocked, case 1} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd client id
|
|
set cid [$rd read]
|
|
r fsl.push k 33
|
|
$rd fsl.bpopgt k 33 0
|
|
r fsl.push k 34
|
|
assert_equal {34} [$rd read]
|
|
r client kill id $cid ;# try to smoke-out client-related memory leak
|
|
}
|
|
|
|
test {Module client blocked on keys (with metadata): Blocked, case 2} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd fsl.bpopgt k 35 0
|
|
r fsl.push k 33
|
|
r fsl.push k 34
|
|
r fsl.push k 35
|
|
r fsl.push k 36
|
|
assert_equal {36} [$rd read]
|
|
}
|
|
|
|
test {Module client blocked on keys (with metadata): Blocked, CLIENT KILL} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd client id
|
|
set cid [$rd read]
|
|
$rd fsl.bpopgt k 35 0
|
|
r client kill id $cid ;# try to smoke-out client-related memory leak
|
|
}
|
|
|
|
test {Module client blocked on keys (with metadata): Blocked, CLIENT UNBLOCK TIMEOUT} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd client id
|
|
set cid [$rd read]
|
|
$rd fsl.bpopgt k 35 0
|
|
r client unblock $cid timeout ;# try to smoke-out client-related memory leak
|
|
assert_equal {Request timedout} [$rd read]
|
|
}
|
|
|
|
test {Module client blocked on keys (with metadata): Blocked, CLIENT UNBLOCK ERROR} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd client id
|
|
set cid [$rd read]
|
|
$rd fsl.bpopgt k 35 0
|
|
r client unblock $cid error ;# try to smoke-out client-related memory leak
|
|
assert_error "*unblocked*" {$rd read}
|
|
}
|
|
|
|
test {Module client blocked on keys does not wake up on wrong type} {
|
|
r del k
|
|
set rd [redis_deferring_client]
|
|
$rd fsl.bpop2 k 0
|
|
r lpush k 12
|
|
r lpush k 13
|
|
r lpush k 14
|
|
r del k
|
|
r fsl.push k 33
|
|
r fsl.push k 34
|
|
assert_equal {34 33} [$rd read]
|
|
}
|
|
}
|