Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
c95a582a
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
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 搜索 >>
提交
c95a582a
编写于
5月 30, 2019
作者:
M
Madelyn Olson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add configuration option for allowing reads on cluster down
上级
e9b99c78
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
3 deletion
+30
-3
redis.conf
redis.conf
+16
-0
src/cluster.c
src/cluster.c
+10
-3
src/config.c
src/config.c
+2
-0
src/server.h
src/server.h
+2
-0
未找到文件。
redis.conf
浏览文件 @
c95a582a
...
@@ -1194,6 +1194,22 @@ lua-time-limit 5000
...
@@ -1194,6 +1194,22 @@ lua-time-limit 5000
#
#
# cluster-replica-no-failover no
# cluster-replica-no-failover no
# This option, when set to yes, allows nodes to serve read traffic while the
# the cluster is in a down state, as long as it believes it owns the slots.
#
# This is useful for two cases. The first case is for when an application
# doesn't require consistency of data during node failures or network partitions.
# One example of this is a cache, where as long as the node has the data it
# should be able to serve it.
#
# The second use case is for configurations that don't meet the recommended
# three shards but want to enable cluster mode and scale later. A
# master outage in a 1 or 2 shard configuration causes a read/write outage to the
# entire cluster without this option set, with it set there is only a write outage.
# Without a quorum of masters, slot ownership will not change automatically.
#
# cluster-allow-reads-when-down no
# In order to setup your cluster make sure to read the documentation
# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.
# available at http://redis.io web site.
...
...
src/cluster.c
浏览文件 @
c95a582a
...
@@ -5595,8 +5595,12 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
...
@@ -5595,8 +5595,12 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
* without redirections or errors in all the cases. */
* without redirections or errors in all the cases. */
if
(
n
==
NULL
)
return
myself
;
if
(
n
==
NULL
)
return
myself
;
/* Cluster is globally down but we got keys? We can't serve the request. */
/* Cluster is globally down but we got keys? We only serve the request
if
(
server
.
cluster
->
state
!=
CLUSTER_OK
)
{
* 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
;
if
(
error_code
)
*
error_code
=
CLUSTER_REDIR_DOWN_STATE
;
return
NULL
;
return
NULL
;
}
}
...
@@ -5701,7 +5705,10 @@ int clusterRedirectBlockedClientIfNeeded(client *c) {
...
@@ -5701,7 +5705,10 @@ int clusterRedirectBlockedClientIfNeeded(client *c) {
dictEntry
*
de
;
dictEntry
*
de
;
dictIterator
*
di
;
dictIterator
*
di
;
/* If the cluster is down, unblock the client with the right error. */
/* If the cluster is down, unblock the client with the right error.
* If the cluster is configured to allow reads on cluster down, we
* still want to emit this error since a write will be required
* to unblock them which may never come. */
if
(
server
.
cluster
->
state
==
CLUSTER_FAIL
)
{
if
(
server
.
cluster
->
state
==
CLUSTER_FAIL
)
{
clusterRedirectClient
(
c
,
NULL
,
0
,
CLUSTER_REDIR_DOWN_STATE
);
clusterRedirectClient
(
c
,
NULL
,
0
,
CLUSTER_REDIR_DOWN_STATE
);
return
1
;
return
1
;
...
...
src/config.c
浏览文件 @
c95a582a
...
@@ -2166,6 +2166,8 @@ standardConfig configs[] = {
...
@@ -2166,6 +2166,8 @@ standardConfig configs[] = {
createBoolConfig
(
"syslog-enabled"
,
NULL
,
IMMUTABLE_CONFIG
,
server
.
syslog_enabled
,
0
,
NULL
,
NULL
),
createBoolConfig
(
"syslog-enabled"
,
NULL
,
IMMUTABLE_CONFIG
,
server
.
syslog_enabled
,
0
,
NULL
,
NULL
),
createBoolConfig
(
"cluster-enabled"
,
NULL
,
IMMUTABLE_CONFIG
,
server
.
cluster_enabled
,
0
,
NULL
,
NULL
),
createBoolConfig
(
"cluster-enabled"
,
NULL
,
IMMUTABLE_CONFIG
,
server
.
cluster_enabled
,
0
,
NULL
,
NULL
),
createBoolConfig
(
"appendonly"
,
NULL
,
MODIFIABLE_CONFIG
,
server
.
aof_enabled
,
0
,
NULL
,
updateAppendonly
),
createBoolConfig
(
"appendonly"
,
NULL
,
MODIFIABLE_CONFIG
,
server
.
aof_enabled
,
0
,
NULL
,
updateAppendonly
),
createBoolConfig
(
"cluster-allow-reads-when-down"
,
NULL
,
MODIFIABLE_CONFIG
,
server
.
cluster_allow_reads_when_down
,
0
,
NULL
,
NULL
},
/* String Configs */
/* String Configs */
createStringConfig
(
"aclfile"
,
NULL
,
IMMUTABLE_CONFIG
,
ALLOW_EMPTY_STRING
,
server
.
acl_filename
,
""
,
NULL
,
NULL
),
createStringConfig
(
"aclfile"
,
NULL
,
IMMUTABLE_CONFIG
,
ALLOW_EMPTY_STRING
,
server
.
acl_filename
,
""
,
NULL
,
NULL
),
...
...
src/server.h
浏览文件 @
c95a582a
...
@@ -1334,6 +1334,8 @@ struct redisServer {
...
@@ -1334,6 +1334,8 @@ struct redisServer {
to set in order to suppress certain
to set in order to suppress certain
native Redis Cluster features. Check the
native Redis Cluster features. Check the
REDISMODULE_CLUSTER_FLAG_*. */
REDISMODULE_CLUSTER_FLAG_*. */
int
cluster_allow_reads_when_down
;
/* Are reads allowed when the cluster
is down? */
/* Scripting */
/* Scripting */
lua_State
*
lua
;
/* The Lua interpreter. We use just one for all clients */
lua_State
*
lua
;
/* The Lua interpreter. We use just one for all clients */
client
*
lua_client
;
/* The "fake client" to query Redis from Lua */
client
*
lua_client
;
/* The "fake client" to query Redis from Lua */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录