From cc4f63d67afa0636eeb344b648a17a5ecd5d1c49 Mon Sep 17 00:00:00 2001 From: Twice Date: Sat, 16 Nov 2024 14:22:40 +0800 Subject: [PATCH] feat(cmd): all blocking commands should be no-script (#2666) --- .gitignore | 1 + src/commands/cmd_list.cc | 7 +++---- src/commands/cmd_server.cc | 2 +- src/commands/commander.h | 8 ++++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c9a9027a069..cd2fd010b28 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ testdb build cmake-build-* +build-* diff --git a/src/commands/cmd_list.cc b/src/commands/cmd_list.cc index 1a9f5d03dfc..6b97eb1557a 100644 --- a/src/commands/cmd_list.cc +++ b/src/commands/cmd_list.cc @@ -894,10 +894,9 @@ class CommandLPos : public Commander { PosSpec spec_; }; -REDIS_REGISTER_COMMANDS(List, MakeCmdAttr("blpop", -3, "write no-script blocking", 1, -2, 1), - MakeCmdAttr("brpop", -3, "write no-script blocking", 1, -2, 1), - MakeCmdAttr("blmpop", -5, "write no-script blocking", - CommandBLMPop::keyRangeGen), +REDIS_REGISTER_COMMANDS(List, MakeCmdAttr("blpop", -3, "write blocking", 1, -2, 1), + MakeCmdAttr("brpop", -3, "write blocking", 1, -2, 1), + MakeCmdAttr("blmpop", -5, "write blocking", CommandBLMPop::keyRangeGen), MakeCmdAttr("lindex", 3, "read-only", 1, 1, 1), MakeCmdAttr("linsert", 5, "write slow", 1, 1, 1), MakeCmdAttr("llen", 2, "read-only", 1, 1, 1), diff --git a/src/commands/cmd_server.cc b/src/commands/cmd_server.cc index e2938267710..ef424a14c81 100644 --- a/src/commands/cmd_server.cc +++ b/src/commands/cmd_server.cc @@ -1343,7 +1343,7 @@ REDIS_REGISTER_COMMANDS(Server, MakeCmdAttr("auth", 2, "read-only o MakeCmdAttr("slowlog", -2, "read-only", NO_KEY), MakeCmdAttr("perflog", -2, "read-only", NO_KEY), MakeCmdAttr("client", -2, "read-only", NO_KEY), - MakeCmdAttr("monitor", 1, "read-only no-multi", NO_KEY), + MakeCmdAttr("monitor", 1, "read-only no-multi no-script", NO_KEY), MakeCmdAttr("shutdown", 1, "read-only no-multi no-script", NO_KEY), MakeCmdAttr("quit", 1, "read-only", NO_KEY), MakeCmdAttr("scan", -2, "read-only", NO_KEY), diff --git a/src/commands/commander.h b/src/commands/commander.h index ac3d3aa9939..bf172a79408 100644 --- a/src/commands/commander.h +++ b/src/commands/commander.h @@ -328,9 +328,13 @@ inline uint64_t ParseCommandFlags(const std::string &description, const std::str flags |= kCmdNoDBSizeCheck; else if (flag == "slow") flags |= kCmdSlow; - else if (flag == "blocking") + else if (flag == "blocking") { flags |= kCmdBlocking; - else { + + // blocking commands should always be no-script + // TODO: we can relax this restriction if scripting becomes non-exclusive + flags |= kCmdNoScript; + } else { std::cout << fmt::format("Encountered non-existent flag '{}' in command {} in command attribute parsing", flag, cmd_name) << std::endl;