Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
d2bc6dc3
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
d2bc6dc3
编写于
11月 12, 2013
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sentinel: new failover algo, desync slaves and update config epoch.
上级
4a128b94
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
1 deletion
+21
-1
src/sentinel.c
src/sentinel.c
+21
-1
未找到文件。
src/sentinel.c
浏览文件 @
d2bc6dc3
...
...
@@ -1509,6 +1509,12 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
(
ri
->
master
->
failover_state
==
SENTINEL_FAILOVER_STATE_WAIT_PROMOTION
))
{
/* Now that we are sure the slave was reconfigured as a master
* set the master configuration epoch to the epoch we won the
* election to perform this failover. This will force the other
* Sentinels to update their config (assuming there is not
* a newer one already available). */
ri
->
master
->
config_epoch
=
ri
->
master
->
failover_epoch
;
ri
->
master
->
failover_state
=
SENTINEL_FAILOVER_STATE_RECONF_SLAVES
;
ri
->
master
->
failover_state_change_time
=
mstime
();
sentinelEvent
(
REDIS_WARNING
,
"+promoted-slave"
,
ri
,
"%@"
);
...
...
@@ -2417,6 +2423,13 @@ char *sentinelVoteLeader(sentinelRedisInstance *master, uint64_t req_epoch, char
master
->
leader_epoch
=
sentinel
.
current_epoch
;
sentinelEvent
(
REDIS_WARNING
,
"+vote-for-leader"
,
master
,
"%s %llu"
,
master
->
leader
,
(
unsigned
long
long
)
master
->
leader_epoch
);
/* If we did not voted for ourselves, set the master failover start
* time to now, in order to force a delay before we can start a
* failover for the same master.
*
* The random addition is useful to desynchronize a bit the slaves
* and reduce the chance that no slave gets majority. */
master
->
failover_start_time
=
mstime
()
+
rand
()
%
2000
;
}
*
leader_epoch
=
master
->
leader_epoch
;
...
...
@@ -2671,7 +2684,14 @@ void sentinelFailoverWaitStart(sentinelRedisInstance *ri) {
sdsfree
(
leader
);
/* If I'm not the leader, I can't continue with the failover. */
if
(
!
isleader
)
return
;
if
(
!
isleader
)
{
/* Abort the failover if I'm not the leader after some time. */
if
(
mstime
()
-
ri
->
failover_start_time
>
10000
)
{
sentinelEvent
(
REDIS_WARNING
,
"-failover-abort-not-elected"
,
ri
,
"%@"
);
sentinelAbortFailover
(
ri
);
}
return
;
}
sentinelEvent
(
REDIS_WARNING
,
"+elected-leader"
,
ri
,
"%@"
);
/* Start the failover going to the next state if enough time has
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录