summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadelyn Olson <34459052+madolson@users.noreply.github.com>2022-11-15 17:21:27 -0800
committerOran Agra <oran@redislabs.com>2022-12-12 17:36:34 +0200
commita26ac7ebbc55b1b49ec62b31adb277756d57a7db (patch)
tree40b60df18cd89f23de59b9e6a5fe1077003191a9
parent7ad786db2ee61e33b6a96de8c50b53785f56f556 (diff)
downloadredis-a26ac7ebbc55b1b49ec62b31adb277756d57a7db.tar.gz
Explicitly send function commands to monitor (#11510)
Both functions and eval are marked as "no-monitor", since we want to explicitly feed in the script command before the commands generated by the script. Note that we want this behavior generally, so that commands can redact arguments before being added to the monitor. (cherry picked from commit d136bf28307ed2add5a0b709586433f4cffd70a7)
-rw-r--r--src/functions.c3
-rw-r--r--tests/unit/introspection.tcl13
2 files changed, 16 insertions, 0 deletions
diff --git a/src/functions.c b/src/functions.c
index 1e81bf6bc..9a2a5fc2e 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -616,6 +616,9 @@ uint64_t fcallGetCommandFlags(client *c, uint64_t cmd_flags) {
}
static void fcallCommandGeneric(client *c, int ro) {
+ /* Functions need to be fed to monitors before the commands they execute. */
+ replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc);
+
robj *function_name = c->argv[1];
functionInfo *fi = dictFetchValue(curr_functions_lib_ctx->functions, function_name->ptr);
if (!fi) {
diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl
index 73f1649a7..9c149bfd8 100644
--- a/tests/unit/introspection.tcl
+++ b/tests/unit/introspection.tcl
@@ -77,6 +77,19 @@ start_server {tags {"introspection"}} {
$rd close
}
+ test {MONITOR can log commands issued by functions} {
+ r function load replace {#!lua name=test
+ redis.register_function('test', function() return redis.call('set', 'foo', 'bar') end)
+ }
+ set rd [redis_deferring_client]
+ $rd monitor
+ $rd read ;# Discard the OK
+ r fcall test 0
+ assert_match {*fcall*test*} [$rd read]
+ assert_match {*lua*"set"*"foo"*"bar"*} [$rd read]
+ $rd close
+ }
+
test {MONITOR supports redacting command arguments} {
set rd [redis_deferring_client]
$rd monitor