Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
redis
提交
576a0890
R
redis
项目概览
dk131072
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
576a0890
编写于
10月 30, 2019
作者:
M
Madelyn Olson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split error message so dependandent callers give a useful result
上级
44aa22c6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
12 deletion
+27
-12
src/cluster.c
src/cluster.c
+15
-8
src/cluster.h
src/cluster.h
+1
-0
src/module.c
src/module.c
+4
-1
src/scripting.c
src/scripting.c
+7
-3
未找到文件。
src/cluster.c
浏览文件 @
576a0890
...
...
@@ -5476,8 +5476,8 @@ void readwriteCommand(client *c) {
* already "down" but it is fragile to rely on the update of the global state,
* so we also handle it here.
*
* CLUSTER_REDIR_DOWN_STATE
if the cluster is down but the user attempts to
* execute a command that addresses one or more keys. */
* CLUSTER_REDIR_DOWN_STATE
and CLUSTER_REDIR_DOWN_RO_STATE if the cluster is
*
down but the user attempts to
execute a command that addresses one or more keys. */
clusterNode
*
getNodeByQuery
(
client
*
c
,
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
hashslot
,
int
*
error_code
)
{
clusterNode
*
n
=
NULL
;
robj
*
firstkey
=
NULL
;
...
...
@@ -5597,12 +5597,17 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
/* Cluster is globally down but we got keys? We only serve the request
* if it is a read command and when allow_reads_when_down is enabled. */
if
((
server
.
cluster
->
state
!=
CLUSTER_OK
)
&&
!
(
server
.
cluster_allow_reads_when_down
&&
((
cmd
->
flags
&
CMD_READONLY
)
||
(
cmd
->
proc
==
evalCommand
)
||
(
cmd
->
proc
==
evalShaCommand
))))
{
if
(
error_code
)
*
error_code
=
CLUSTER_REDIR_DOWN_STATE
;
return
NULL
;
if
(
server
.
cluster
->
state
!=
CLUSTER_OK
)
{
if
(
!
server
.
cluster_allow_reads_when_down
)
{
if
(
error_code
)
*
error_code
=
CLUSTER_REDIR_DOWN_STATE
;
return
NULL
;
}
if
(
!
(
cmd
->
flags
&
CMD_READONLY
)
&&
!
(
cmd
->
proc
==
evalCommand
)
&&
!
(
cmd
->
proc
==
evalShaCommand
))
{
if
(
error_code
)
*
error_code
=
CLUSTER_REDIR_DOWN_RO_STATE
;
return
NULL
;
}
}
/* Return the hashslot by reference. */
...
...
@@ -5671,6 +5676,8 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co
addReplySds
(
c
,
sdsnew
(
"-TRYAGAIN Multiple keys request during rehashing of slot
\r\n
"
));
}
else
if
(
error_code
==
CLUSTER_REDIR_DOWN_STATE
)
{
addReplySds
(
c
,
sdsnew
(
"-CLUSTERDOWN The cluster is down
\r\n
"
));
}
else
if
(
error_code
==
CLUSTER_REDIR_DOWN_RO_STATE
)
{
addReplySds
(
c
,
sdsnew
(
"-CLUSTERDOWN The cluster is down and only accepts read commands
\r\n
"
));
}
else
if
(
error_code
==
CLUSTER_REDIR_DOWN_UNBOUND
)
{
addReplySds
(
c
,
sdsnew
(
"-CLUSTERDOWN Hash slot not served
\r\n
"
));
}
else
if
(
error_code
==
CLUSTER_REDIR_MOVED
||
...
...
src/cluster.h
浏览文件 @
576a0890
...
...
@@ -29,6 +29,7 @@
#define CLUSTER_REDIR_MOVED 4
/* -MOVED redirection required. */
#define CLUSTER_REDIR_DOWN_STATE 5
/* -CLUSTERDOWN, global state. */
#define CLUSTER_REDIR_DOWN_UNBOUND 6
/* -CLUSTERDOWN, unbound slot. */
#define CLUSTER_REDIR_DOWN_RO_STATE 7
/* -CLUSTERDOWN, allow reads. */
struct
clusterNode
;
...
...
src/module.c
浏览文件 @
576a0890
...
...
@@ -3176,6 +3176,7 @@ fmterr:
* EPERM: operation in Cluster instance with key in non local slot.
* EROFS: operation in Cluster instance when a write command is sent
* in a readonly state.
* ENETDOWN: operation in Cluster instance when cluster is down.
*
* This API is documented here: https://redis.io/topics/modules-intro
*/
...
...
@@ -3240,8 +3241,10 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch
if
(
getNodeByQuery
(
c
,
c
->
cmd
,
c
->
argv
,
c
->
argc
,
NULL
,
&
error_code
)
!=
server
.
cluster
->
myself
)
{
if
(
error_code
==
CLUSTER_REDIR_DOWN_STATE
)
{
if
(
error_code
==
CLUSTER_REDIR_DOWN_
RO_
STATE
)
{
errno
=
EROFS
;
}
else
if
(
error_code
==
CLUSTER_REDIR_DOWN_STATE
)
{
errno
=
ENETDOWN
;
}
else
{
errno
=
EPERM
;
}
...
...
src/scripting.c
浏览文件 @
576a0890
...
...
@@ -686,11 +686,15 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
if
(
getNodeByQuery
(
c
,
c
->
cmd
,
c
->
argv
,
c
->
argc
,
NULL
,
&
error_code
)
!=
server
.
cluster
->
myself
)
{
if
(
error_code
==
CLUSTER_REDIR_DOWN_STATE
)
{
if
(
error_code
==
CLUSTER_REDIR_DOWN_
RO_
STATE
)
{
luaPushError
(
lua
,
"Lua script attempted execute a write command while "
"Lua script attempted to execute a write command while the"
"cluster is down and readonly"
);
}
else
if
(
error_code
==
CLUSTER_REDIR_DOWN_STATE
)
{
luaPushError
(
lua
,
"Lua script attempted to execute a command while the"
"cluster is down"
);
}
else
{
}
else
{
}
luaPushError
(
lua
,
"Lua script attempted to access a non local key in a "
"cluster node"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录