Binbin 1892f8a731
Add server log when module load fails with busy name (#1084)
Currently when module loading fails due to busy name, we
don't have a clean way to assist to troubleshooting.

Case 1: when loading the same module multiple times, we can
not detemine the cause of its failure without referring to
the module list or the earliest module load log. The log
may not exist and sometimes it is difficult for people
to associate module list.

Case 2: when multiple modules use the same module name,
we can not quickly associate the busy name without referring
to the module list and the earliest module load log.
Different people wrote modules with the same module name,
they don't easily associate module name.

So in this PR, when doing module onload, we will try to
print a busy name log if this happen. Currently we check
ctx.module since if it is NULL it means the Init call
failed, and Init currently only fails with busy name.

It's kind of ugly. It would have been nice if we could have had a
better way for onload to signal why the load failed.

Signed-off-by: Binbin <binloveplay1314@qq.com>
2024-10-09 16:10:29 +08:00

52 lines
1.5 KiB
Tcl

set testmodule [file normalize tests/modules/basics.so]
start_server {tags {"modules"}} {
r module load $testmodule
test {test module api basics} {
r test.basics
} {ALL TESTS PASSED}
test {test rm_call auto mode} {
r hello 2
set reply [r test.rmcallautomode]
assert_equal [lindex $reply 0] f1
assert_equal [lindex $reply 1] v1
assert_equal [lindex $reply 2] f2
assert_equal [lindex $reply 3] v2
r hello 3
set reply [r test.rmcallautomode]
assert_equal [dict get $reply f1] v1
assert_equal [dict get $reply f2] v2
}
test {test get resp} {
foreach resp {3 2} {
if {[lsearch $::denytags "resp3"] >= 0} {
if {$resp == 3} {continue}
} elseif {$::force_resp3} {
if {$resp == 2} {continue}
}
r hello $resp
set reply [r test.getresp]
assert_equal $reply $resp
r hello 2
}
}
test "Busy module name" {
assert_error {ERR Error loading the extension. Please check the server logs.} {r module load $testmodule}
verify_log_message 0 "*Module name is busy*" 0
}
test "Unload the module - basics" {
assert_equal {OK} [r module unload test]
}
}
start_server {tags {"modules external:skip"} overrides {enable-module-command no}} {
test {module command disabled} {
assert_error "ERR *MODULE command not allowed*" {r module load $testmodule}
}
}