diff options
author | Shay Fadida <shayfadida@gmail.com> | 2022-09-21 08:10:03 +0300 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2022-09-21 22:42:01 +0300 |
commit | c9eabbf9b1e9369ac4091f659e020b6fc96bc4fd (patch) | |
tree | ae9d28c2379f10be92d28c35b3a03b112d9e08d8 | |
parent | 842fd1fbdf2d3a91072d649dc9a9a27f65bde86a (diff) | |
download | redis-c9eabbf9b1e9369ac4091f659e020b6fc96bc4fd.tar.gz |
Fix missing sections for INFO ALL with module (#11291)
When using `INFO ALL <section>`, when `section` is a specific module section.
Redis will not print the additional section(s).
The fix in this case, will search the modules info sections if the user provided additional sections to `ALL`.
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit eedb8b172474dd7776d9bbb0f2954a1394027289)
-rw-r--r-- | src/server.c | 10 | ||||
-rw-r--r-- | tests/unit/moduleapi/infotest.tcl | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/server.c b/src/server.c index de32ff847..d7821d4e0 100644 --- a/src/server.c +++ b/src/server.c @@ -5969,9 +5969,13 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { } /* Get info from modules. - * if user asked for "everything" or "modules", or a specific section - * that's not found yet. */ - if (everything || dictFind(section_dict, "modules") != NULL || sections < (int)dictSize(section_dict)) { + * Returned when the user asked for "everything", "modules", or a specific module section. + * We're not aware of the module section names here, and we rather avoid the search when we can. + * so we proceed if there's a requested section name that's not found yet, or when the user asked + * for "all" with any additional section names. */ + if (everything || dictFind(section_dict, "modules") != NULL || sections < (int)dictSize(section_dict) || + (all_sections && dictSize(section_dict))) + { info = modulesCollectInfo(info, everything || dictFind(section_dict, "modules") != NULL ? NULL: section_dict, diff --git a/tests/unit/moduleapi/infotest.tcl b/tests/unit/moduleapi/infotest.tcl index 354487a19..ccd8c4ecb 100644 --- a/tests/unit/moduleapi/infotest.tcl +++ b/tests/unit/moduleapi/infotest.tcl @@ -44,6 +44,14 @@ start_server {tags {"modules"}} { assert { [string match "*used_memory*" $info] } } + test {module info all infotest} { + set info [r info all infotest] + # info all infotest should contain both ALL and the module information + assert { [string match "*Spanish*" $info] } + assert { [string match "*infotest_*" $info] } + assert { [string match "*used_memory*" $info] } + } + test {module info everything} { set info [r info everything] # info everything contains all default sections, but not ones for crash report |