Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
989e2ae2
R
redis
项目概览
别团等shy哥发育
/
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,发现更多精彩内容 >>
提交
989e2ae2
编写于
10月 16, 2014
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Diskless replication: trigger diskless RDB transfer if needed.
上级
94e9dd6b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
2 deletion
+37
-2
src/redis.h
src/redis.h
+1
-1
src/replication.c
src/replication.c
+36
-1
未找到文件。
src/redis.h
浏览文件 @
989e2ae2
...
...
@@ -115,7 +115,7 @@ typedef long long mstime_t; /* millisecond time type. */
#define REDIS_DEFAULT_RDB_CHECKSUM 1
#define REDIS_DEFAULT_RDB_FILENAME "dump.rdb"
#define REDIS_DEFAULT_RDB_DISKLESS 0
#define RE
ID
S_DEFAULT_RDB_DISKLESS_DELAY 5
#define RE
DI
S_DEFAULT_RDB_DISKLESS_DELAY 5
#define REDIS_DEFAULT_SLAVE_SERVE_STALE_DATA 1
#define REDIS_DEFAULT_SLAVE_READ_ONLY 1
#define REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY 0
...
...
src/replication.c
浏览文件 @
989e2ae2
...
...
@@ -212,7 +212,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
}
/* Write the command to every slave. */
listRewind
(
slaves
,
&
li
);
listRewind
(
s
erver
.
s
laves
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
redisClient
*
slave
=
ln
->
value
;
...
...
@@ -1941,6 +1941,41 @@ void replicationCron(void) {
replicationScriptCacheFlush
();
}
/* If we are using diskless replication and there are slaves waiting
* in WAIT_BGSAVE_START state, check if enough seconds elapsed and
* start one. */
if
(
server
.
repl_diskless
&&
server
.
rdb_child_pid
==
-
1
&&
server
.
aof_child_pid
==
-
1
)
{
time_t
idle
,
max_idle
=
0
;
int
slaves_waiting
=
0
;
listNode
*
ln
;
listIter
li
;
listRewind
(
server
.
slaves
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
redisClient
*
slave
=
ln
->
value
;
if
(
slave
->
replstate
==
REDIS_REPL_WAIT_BGSAVE_START
)
{
idle
=
server
.
unixtime
-
slave
->
lastinteraction
;
if
(
idle
>
max_idle
)
max_idle
=
idle
;
slaves_waiting
++
;
}
}
if
(
slaves_waiting
&&
max_idle
>
REDIS_DEFAULT_RDB_DISKLESS_DELAY
)
{
/* Let's start a BGSAVE with disk target. */
if
(
startBgsaveForReplication
()
==
REDIS_OK
)
{
/* It started! We need to change the state of slaves
* from WAIT_BGSAVE_START to WAIT_BGSAVE_END. */
while
((
ln
=
listNext
(
&
li
)))
{
redisClient
*
slave
=
ln
->
value
;
if
(
slave
->
replstate
==
REDIS_REPL_WAIT_BGSAVE_START
)
slave
->
replstate
=
REDIS_REPL_WAIT_BGSAVE_END
;
}
}
}
}
/* Refresh the number of slaves with lag <= min-slaves-max-lag. */
refreshGoodSlavesCount
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录