summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-06-30 21:32:40 +0800
committerGitHub <noreply@github.com>2022-06-30 16:32:40 +0300
commit35e836c26d40447f337979a61bb8cb3ed0575796 (patch)
tree3dbac4dbc977ea266ab15cb69eaab865aa11bc36
parent51da5c3dde38b138c68733977e53eee789e51d10 (diff)
downloadredis-35e836c26d40447f337979a61bb8cb3ed0575796.tar.gz
Add SENTINEL command flag to CLIENT/COMMANDS subcommands (#10904)
This was harmless because we marked the parent command with SENTINEL flag. So the populateCommandTable was ok. And we also don't show the flag (SENTINEL and ONLY-SENTNEL) in COMMAND INFO. In this PR, we also add the same CMD_SENTINEL and CMD_ONLY_SENTINEL flags check when populating the sub-commands. so that in the future it'll be possible to add some sub-commands to sentinel or sentinel-only but not others.
-rw-r--r--src/commands.c46
-rw-r--r--src/commands/client-caching.json3
-rw-r--r--src/commands/client-getname.json3
-rw-r--r--src/commands/client-getredir.json3
-rw-r--r--src/commands/client-help.json3
-rw-r--r--src/commands/client-id.json3
-rw-r--r--src/commands/client-info.json3
-rw-r--r--src/commands/client-kill.json3
-rw-r--r--src/commands/client-list.json3
-rw-r--r--src/commands/client-no-evict.json3
-rw-r--r--src/commands/client-pause.json3
-rw-r--r--src/commands/client-reply.json3
-rw-r--r--src/commands/client-setname.json3
-rw-r--r--src/commands/client-tracking.json3
-rw-r--r--src/commands/client-trackinginfo.json3
-rw-r--r--src/commands/client-unblock.json3
-rw-r--r--src/commands/client-unpause.json3
-rw-r--r--src/commands/command-count.json3
-rw-r--r--src/commands/command-docs.json3
-rw-r--r--src/commands/command-getkeys.json3
-rw-r--r--src/commands/command-getkeysandflags.json3
-rw-r--r--src/commands/command-help.json3
-rw-r--r--src/commands/command-info.json3
-rw-r--r--src/commands/command-list.json3
-rw-r--r--src/server.c39
-rw-r--r--src/server.h5
-rw-r--r--tests/sentinel/tests/00-base.tcl7
27 files changed, 103 insertions, 63 deletions
diff --git a/src/commands.c b/src/commands.c
index f3cd37b28..63dfd92e3 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -1029,22 +1029,22 @@ struct redisCommandArg CLIENT_UNBLOCK_Args[] = {
/* CLIENT command table */
struct redisCommand CLIENT_Subcommands[] = {
-{"caching","Instruct the server about tracking or not keys in the next request","O(1)","6.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_CACHING_History,CLIENT_CACHING_tips,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_CACHING_Args},
-{"getname","Get the current connection name","O(1)","2.6.9",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_GETNAME_History,CLIENT_GETNAME_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"getredir","Get tracking notifications redirection client ID if any","O(1)","6.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_GETREDIR_History,CLIENT_GETREDIR_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"help","Show helpful text about the different subcommands","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_HELP_History,CLIENT_HELP_tips,clientCommand,2,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"id","Returns the client ID for the current connection","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_ID_History,CLIENT_ID_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"info","Returns information about the current client connection.","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_INFO_History,CLIENT_INFO_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"kill","Kill the connection of a client","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_KILL_History,CLIENT_KILL_tips,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_KILL_Args},
-{"list","Get the list of client connections","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_LIST_History,CLIENT_LIST_tips,clientCommand,-2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_LIST_Args},
-{"no-evict","Set client eviction mode for the current connection","O(1)","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_NO_EVICT_History,CLIENT_NO_EVICT_tips,clientCommand,3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_NO_EVICT_Args},
-{"pause","Stop processing commands from clients for some time","O(1)","2.9.50",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_PAUSE_History,CLIENT_PAUSE_tips,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_PAUSE_Args},
-{"reply","Instruct the server whether to reply to commands","O(1)","3.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_REPLY_History,CLIENT_REPLY_tips,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_REPLY_Args},
-{"setname","Set the current connection name","O(1)","2.6.9",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_SETNAME_History,CLIENT_SETNAME_tips,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_SETNAME_Args},
-{"tracking","Enable or disable server assisted client side caching support","O(1). Some options may introduce additional complexity.","6.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_TRACKING_History,CLIENT_TRACKING_tips,clientCommand,-3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_TRACKING_Args},
-{"trackinginfo","Return information about server assisted client side caching for the current connection","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_TRACKINGINFO_History,CLIENT_TRACKINGINFO_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"unblock","Unblock a client blocked in a blocking command from a different connection","O(log N) where N is the number of client connections","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_UNBLOCK_History,CLIENT_UNBLOCK_tips,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=CLIENT_UNBLOCK_Args},
-{"unpause","Resume processing of clients that were paused","O(N) Where N is the number of paused clients","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_UNPAUSE_History,CLIENT_UNPAUSE_tips,clientCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
+{"caching","Instruct the server about tracking or not keys in the next request","O(1)","6.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_CACHING_History,CLIENT_CACHING_tips,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_CACHING_Args},
+{"getname","Get the current connection name","O(1)","2.6.9",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_GETNAME_History,CLIENT_GETNAME_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"getredir","Get tracking notifications redirection client ID if any","O(1)","6.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_GETREDIR_History,CLIENT_GETREDIR_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"help","Show helpful text about the different subcommands","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_HELP_History,CLIENT_HELP_tips,clientCommand,2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"id","Returns the client ID for the current connection","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_ID_History,CLIENT_ID_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"info","Returns information about the current client connection.","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_INFO_History,CLIENT_INFO_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"kill","Kill the connection of a client","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_KILL_History,CLIENT_KILL_tips,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_KILL_Args},
+{"list","Get the list of client connections","O(N) where N is the number of client connections","2.4.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_LIST_History,CLIENT_LIST_tips,clientCommand,-2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_LIST_Args},
+{"no-evict","Set client eviction mode for the current connection","O(1)","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_NO_EVICT_History,CLIENT_NO_EVICT_tips,clientCommand,3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_NO_EVICT_Args},
+{"pause","Stop processing commands from clients for some time","O(1)","2.9.50",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_PAUSE_History,CLIENT_PAUSE_tips,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_PAUSE_Args},
+{"reply","Instruct the server whether to reply to commands","O(1)","3.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_REPLY_History,CLIENT_REPLY_tips,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_REPLY_Args},
+{"setname","Set the current connection name","O(1)","2.6.9",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_SETNAME_History,CLIENT_SETNAME_tips,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_SETNAME_Args},
+{"tracking","Enable or disable server assisted client side caching support","O(1). Some options may introduce additional complexity.","6.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_TRACKING_History,CLIENT_TRACKING_tips,clientCommand,-3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_TRACKING_Args},
+{"trackinginfo","Return information about server assisted client side caching for the current connection","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_TRACKINGINFO_History,CLIENT_TRACKINGINFO_tips,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"unblock","Unblock a client blocked in a blocking command from a different connection","O(log N) where N is the number of client connections","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_UNBLOCK_History,CLIENT_UNBLOCK_tips,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=CLIENT_UNBLOCK_Args},
+{"unpause","Resume processing of clients that were paused","O(N) Where N is the number of paused clients","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_CONNECTION,CLIENT_UNPAUSE_History,CLIENT_UNPAUSE_tips,clientCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
{0}
};
@@ -4321,13 +4321,13 @@ struct redisCommandArg COMMAND_LIST_Args[] = {
/* COMMAND command table */
struct redisCommand COMMAND_Subcommands[] = {
-{"count","Get total number of Redis commands","O(1)","2.8.13",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_COUNT_History,COMMAND_COUNT_tips,commandCountCommand,2,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"docs","Get array of specific Redis command documentation","O(N) where N is the number of commands to look up","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_DOCS_History,COMMAND_DOCS_tips,commandDocsCommand,-2,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=COMMAND_DOCS_Args},
-{"getkeys","Extract keys given a full Redis command","O(N) where N is the number of arguments to the command","2.8.13",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_GETKEYS_History,COMMAND_GETKEYS_tips,commandGetKeysCommand,-4,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"getkeysandflags","Extract keys and access flags given a full Redis command","O(N) where N is the number of arguments to the command","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_GETKEYSANDFLAGS_History,COMMAND_GETKEYSANDFLAGS_tips,commandGetKeysAndFlagsCommand,-4,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"help","Show helpful text about the different subcommands","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_HELP_History,COMMAND_HELP_tips,commandHelpCommand,2,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION},
-{"info","Get array of specific Redis command details, or all when no argument is given.","O(N) where N is the number of commands to look up","2.8.13",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_INFO_History,COMMAND_INFO_tips,commandInfoCommand,-2,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=COMMAND_INFO_Args},
-{"list","Get an array of Redis command names","O(N) where N is the total number of Redis commands","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_LIST_History,COMMAND_LIST_tips,commandListCommand,-2,CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,.args=COMMAND_LIST_Args},
+{"count","Get total number of Redis commands","O(1)","2.8.13",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_COUNT_History,COMMAND_COUNT_tips,commandCountCommand,2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"docs","Get array of specific Redis command documentation","O(N) where N is the number of commands to look up","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_DOCS_History,COMMAND_DOCS_tips,commandDocsCommand,-2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=COMMAND_DOCS_Args},
+{"getkeys","Extract keys given a full Redis command","O(N) where N is the number of arguments to the command","2.8.13",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_GETKEYS_History,COMMAND_GETKEYS_tips,commandGetKeysCommand,-4,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"getkeysandflags","Extract keys and access flags given a full Redis command","O(N) where N is the number of arguments to the command","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_GETKEYSANDFLAGS_History,COMMAND_GETKEYSANDFLAGS_tips,commandGetKeysAndFlagsCommand,-4,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"help","Show helpful text about the different subcommands","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_HELP_History,COMMAND_HELP_tips,commandHelpCommand,2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION},
+{"info","Get array of specific Redis command details, or all when no argument is given.","O(N) where N is the number of commands to look up","2.8.13",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_INFO_History,COMMAND_INFO_tips,commandInfoCommand,-2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=COMMAND_INFO_Args},
+{"list","Get an array of Redis command names","O(N) where N is the total number of Redis commands","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SERVER,COMMAND_LIST_History,COMMAND_LIST_tips,commandListCommand,-2,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,.args=COMMAND_LIST_Args},
{0}
};
diff --git a/src/commands/client-caching.json b/src/commands/client-caching.json
index de49cfc39..b8beaa8b6 100644
--- a/src/commands/client-caching.json
+++ b/src/commands/client-caching.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-getname.json b/src/commands/client-getname.json
index 89a62e872..515e0ed67 100644
--- a/src/commands/client-getname.json
+++ b/src/commands/client-getname.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-getredir.json b/src/commands/client-getredir.json
index 2313d0713..8d5b23997 100644
--- a/src/commands/client-getredir.json
+++ b/src/commands/client-getredir.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-help.json b/src/commands/client-help.json
index 6f725bae6..fee49f9b8 100644
--- a/src/commands/client-help.json
+++ b/src/commands/client-help.json
@@ -9,7 +9,8 @@
"function": "clientCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-id.json b/src/commands/client-id.json
index e05c8c62a..792da7dbb 100644
--- a/src/commands/client-id.json
+++ b/src/commands/client-id.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-info.json b/src/commands/client-info.json
index 2668eaf14..06fa094bb 100644
--- a/src/commands/client-info.json
+++ b/src/commands/client-info.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-kill.json b/src/commands/client-kill.json
index 398738bb2..452724fe2 100644
--- a/src/commands/client-kill.json
+++ b/src/commands/client-kill.json
@@ -33,7 +33,8 @@
"ADMIN",
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-list.json b/src/commands/client-list.json
index bcd1dcefb..75605cfb1 100644
--- a/src/commands/client-list.json
+++ b/src/commands/client-list.json
@@ -25,7 +25,8 @@
"ADMIN",
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-no-evict.json b/src/commands/client-no-evict.json
index af99348d2..fc0ad71c9 100644
--- a/src/commands/client-no-evict.json
+++ b/src/commands/client-no-evict.json
@@ -11,7 +11,8 @@
"ADMIN",
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-pause.json b/src/commands/client-pause.json
index 3a1d9be83..90b7e3bc9 100644
--- a/src/commands/client-pause.json
+++ b/src/commands/client-pause.json
@@ -17,7 +17,8 @@
"ADMIN",
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-reply.json b/src/commands/client-reply.json
index 59128ca3a..25d2cef72 100644
--- a/src/commands/client-reply.json
+++ b/src/commands/client-reply.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-setname.json b/src/commands/client-setname.json
index 58e5f446d..cc9199fea 100644
--- a/src/commands/client-setname.json
+++ b/src/commands/client-setname.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-tracking.json b/src/commands/client-tracking.json
index 06f1df944..40811f155 100644
--- a/src/commands/client-tracking.json
+++ b/src/commands/client-tracking.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-trackinginfo.json b/src/commands/client-trackinginfo.json
index 0669f9a27..124c44281 100644
--- a/src/commands/client-trackinginfo.json
+++ b/src/commands/client-trackinginfo.json
@@ -10,7 +10,8 @@
"command_flags": [
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-unblock.json b/src/commands/client-unblock.json
index c6690730b..75bdddc29 100644
--- a/src/commands/client-unblock.json
+++ b/src/commands/client-unblock.json
@@ -11,7 +11,8 @@
"ADMIN",
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/client-unpause.json b/src/commands/client-unpause.json
index c25fd0466..661baa0fd 100644
--- a/src/commands/client-unpause.json
+++ b/src/commands/client-unpause.json
@@ -11,7 +11,8 @@
"ADMIN",
"NOSCRIPT",
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-count.json b/src/commands/command-count.json
index 88f7873bd..f2081ca46 100644
--- a/src/commands/command-count.json
+++ b/src/commands/command-count.json
@@ -9,7 +9,8 @@
"function": "commandCountCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-docs.json b/src/commands/command-docs.json
index 68a32f8a1..7dc81d61c 100644
--- a/src/commands/command-docs.json
+++ b/src/commands/command-docs.json
@@ -9,7 +9,8 @@
"function": "commandDocsCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-getkeys.json b/src/commands/command-getkeys.json
index ca655ac32..744726144 100644
--- a/src/commands/command-getkeys.json
+++ b/src/commands/command-getkeys.json
@@ -9,7 +9,8 @@
"function": "commandGetKeysCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-getkeysandflags.json b/src/commands/command-getkeysandflags.json
index 44b3ddcb1..6410835ee 100644
--- a/src/commands/command-getkeysandflags.json
+++ b/src/commands/command-getkeysandflags.json
@@ -9,7 +9,8 @@
"function": "commandGetKeysAndFlagsCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-help.json b/src/commands/command-help.json
index ed759083f..d5ad719f0 100644
--- a/src/commands/command-help.json
+++ b/src/commands/command-help.json
@@ -9,7 +9,8 @@
"function": "commandHelpCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-info.json b/src/commands/command-info.json
index 40d60a3ec..52ab40084 100644
--- a/src/commands/command-info.json
+++ b/src/commands/command-info.json
@@ -15,7 +15,8 @@
],
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/commands/command-list.json b/src/commands/command-list.json
index 49e9558ca..9ef624f07 100644
--- a/src/commands/command-list.json
+++ b/src/commands/command-list.json
@@ -9,7 +9,8 @@
"function": "commandListCommand",
"command_flags": [
"LOADING",
- "STALE"
+ "STALE",
+ "SENTINEL"
],
"acl_categories": [
"CONNECTION"
diff --git a/src/server.c b/src/server.c
index 9e988e516..88ace5d3a 100644
--- a/src/server.c
+++ b/src/server.c
@@ -2793,8 +2793,23 @@ int populateArgsStructure(struct redisCommandArg *args) {
return count;
}
-/* Recursively populate the command structure. */
-void populateCommandStructure(struct redisCommand *c) {
+/* Recursively populate the command structure.
+ *
+ * On success, the function return C_OK. Otherwise C_ERR is returned and we won't
+ * add this command in the commands dict. */
+int populateCommandStructure(struct redisCommand *c) {
+ /* If the command marks with CMD_SENTINEL, it exists in sentinel. */
+ if (!(c->flags & CMD_SENTINEL) && server.sentinel_mode)
+ return C_ERR;
+
+ /* If the command marks with CMD_ONLY_SENTINEL, it only exists in sentinel. */
+ if (c->flags & CMD_ONLY_SENTINEL && !server.sentinel_mode)
+ return C_ERR;
+
+ /* Translate the command string flags description into an actual
+ * set of flags. */
+ setImplicitACLCategories(c);
+
/* Redis commands don't need more args than STATIC_KEY_SPECS_NUM (Number of keys
* specs can be greater than STATIC_KEY_SPECS_NUM only for module commands) */
c->key_specs = c->key_specs_static;
@@ -2828,14 +2843,15 @@ void populateCommandStructure(struct redisCommand *c) {
for (int j = 0; c->subcommands[j].declared_name; j++) {
struct redisCommand *sub = c->subcommands+j;
- /* Translate the command string flags description into an actual
- * set of flags. */
- setImplicitACLCategories(sub);
sub->fullname = catSubCommandFullname(c->declared_name, sub->declared_name);
- populateCommandStructure(sub);
+ if (populateCommandStructure(sub) == C_ERR)
+ continue;
+
commandAddSubcommand(c, sub, sub->declared_name);
}
}
+
+ return C_OK;
}
extern struct redisCommand redisCommandTable[];
@@ -2853,16 +2869,9 @@ void populateCommandTable(void) {
int retval1, retval2;
- setImplicitACLCategories(c);
-
- if (!(c->flags & CMD_SENTINEL) && server.sentinel_mode)
- continue;
-
- if (c->flags & CMD_ONLY_SENTINEL && !server.sentinel_mode)
- continue;
-
c->fullname = sdsnew(c->declared_name);
- populateCommandStructure(c);
+ if (populateCommandStructure(c) == C_ERR)
+ continue;
retval1 = dictAdd(server.commands, sdsdup(c->fullname), c);
/* Populate an additional dictionary that will be unaffected
diff --git a/src/server.h b/src/server.h
index 6beae765b..3021e7683 100644
--- a/src/server.h
+++ b/src/server.h
@@ -2186,9 +2186,10 @@ typedef int redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, ge
* or may just execute read commands. A command can not be marked
* both CMD_WRITE and CMD_MAY_REPLICATE
*
- * CMD_SENTINEL: This command is present in sentinel mode too.
+ * CMD_SENTINEL: This command is present in sentinel mode.
*
- * CMD_SENTINEL_ONLY: This command is present only when in sentinel mode.
+ * CMD_ONLY_SENTINEL: This command is present only when in sentinel mode.
+ * And should be removed from redis.
*
* CMD_NO_MANDATORY_KEYS: This key arguments for this command are optional.
*
diff --git a/tests/sentinel/tests/00-base.tcl b/tests/sentinel/tests/00-base.tcl
index 1a9879a20..761ee82d1 100644
--- a/tests/sentinel/tests/00-base.tcl
+++ b/tests/sentinel/tests/00-base.tcl
@@ -12,6 +12,13 @@ if {$::simulate_error} {
}
}
+test "Sentinel commands sanity check" {
+ foreach_sentinel_id id {
+ assert_equal {72} [llength [S $id command list]]
+ assert_equal {15} [S $id command count]
+ }
+}
+
test "Basic failover works if the master is down" {
set old_port [RPort $master_id]
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]