Commit 39e5a6fa authored by uriyage's avatar uriyage Committed by Oran Agra
Browse files

Module CLIENT_CHANGE, Fix crash on free blocked client with DB!=0 (#11500)



In moduleFireServerEvent we change the real client DB to 0 on freeClient in case the event is REDISMODULE_EVENT_CLIENT_CHANGE.
It results in a crash if the client is blocked on a key on other than DB 0.

The DB change is not necessary even for module-client, as we set its DB to 0 on either createClient or moduleReleaseTempClient.
Co-authored-by: default avatarMadelyn Olson <34459052+madolson@users.noreply.github.com>
Co-authored-by: default avatarBinbin <binloveplay1314@qq.com>
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
(cherry picked from commit e4eb18b3)
parent 4ac3d79b
...@@ -8321,7 +8321,8 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { ...@@ -8321,7 +8321,8 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) {
* up to the specific event setup to change it when it makes * up to the specific event setup to change it when it makes
* sense. For instance for FLUSHDB events we select the correct * sense. For instance for FLUSHDB events we select the correct
* DB automatically. */ * DB automatically. */
selectDb(ctx.client, 0); if (!real_client_used)
selectDb(ctx.client, 0);
/* Event specific context and data pointer setup. */ /* Event specific context and data pointer setup. */
if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) {
......
...@@ -12,6 +12,19 @@ tags "modules" { ...@@ -12,6 +12,19 @@ tags "modules" {
assert {[r hooks.event_count client-disconnected] > 1} assert {[r hooks.event_count client-disconnected] > 1}
} }
test {Test module client change event for blocked client} {
set rd [redis_deferring_client]
# select db other than 0
$rd select 1
# block on key
$rd brpop foo 0
# kill blocked client
r client kill skipme yes
# assert server is still up
assert_equal [r ping] PONG
$rd close
}
test {Test module cron hook} { test {Test module cron hook} {
after 100 after 100
assert {[r hooks.event_count cron-loop] > 0} assert {[r hooks.event_count cron-loop] > 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