Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
70735243
Commit
70735243
authored
Oct 27, 2014
by
antirez
Browse files
Diskless sync delay is now configurable.
parent
c4dbc7cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
70735243
...
@@ -274,6 +274,12 @@ void loadServerConfigFromString(char *config) {
...
@@ -274,6 +274,12 @@ void loadServerConfigFromString(char *config) {
if
((
server
.
repl_diskless_sync
=
yesnotoi
(
argv
[
1
]))
==
-
1
)
{
if
((
server
.
repl_diskless_sync
=
yesnotoi
(
argv
[
1
]))
==
-
1
)
{
err
=
"argument must be 'yes' or 'no'"
;
goto
loaderr
;
err
=
"argument must be 'yes' or 'no'"
;
goto
loaderr
;
}
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"repl-diskless-sync-delay"
)
&&
argc
==
2
)
{
server
.
repl_diskless_sync_delay
=
atoi
(
argv
[
1
]);
if
(
server
.
repl_diskless_sync_delay
<
0
)
{
err
=
"repl-diskless-sync-delay can't be negative"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"repl-backlog-size"
)
&&
argc
==
2
)
{
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"repl-backlog-size"
)
&&
argc
==
2
)
{
long
long
size
=
memtoll
(
argv
[
1
],
NULL
);
long
long
size
=
memtoll
(
argv
[
1
],
NULL
);
if
(
size
<=
0
)
{
if
(
size
<=
0
)
{
...
@@ -920,6 +926,10 @@ void configSetCommand(redisClient *c) {
...
@@ -920,6 +926,10 @@ void configSetCommand(redisClient *c) {
if
(
yn
==
-
1
)
goto
badfmt
;
if
(
yn
==
-
1
)
goto
badfmt
;
server
.
repl_diskless_sync
=
yn
;
server
.
repl_diskless_sync
=
yn
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"repl-diskless-sync-delay"
))
{
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
server
.
repl_diskless_sync_delay
=
ll
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"slave-priority"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"slave-priority"
))
{
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
ll
<
0
)
goto
badfmt
;
...
@@ -1058,6 +1068,7 @@ void configGetCommand(redisClient *c) {
...
@@ -1058,6 +1068,7 @@ void configGetCommand(redisClient *c) {
config_get_numerical_field
(
"cluster-node-timeout"
,
server
.
cluster_node_timeout
);
config_get_numerical_field
(
"cluster-node-timeout"
,
server
.
cluster_node_timeout
);
config_get_numerical_field
(
"cluster-migration-barrier"
,
server
.
cluster_migration_barrier
);
config_get_numerical_field
(
"cluster-migration-barrier"
,
server
.
cluster_migration_barrier
);
config_get_numerical_field
(
"cluster-slave-validity-factor"
,
server
.
cluster_slave_validity_factor
);
config_get_numerical_field
(
"cluster-slave-validity-factor"
,
server
.
cluster_slave_validity_factor
);
config_get_numerical_field
(
"repl-diskless-sync-delay"
,
server
.
repl_diskless_sync_delay
);
/* Bool (yes/no) values */
/* Bool (yes/no) values */
config_get_bool_field
(
"cluster-require-full-coverage"
,
config_get_bool_field
(
"cluster-require-full-coverage"
,
...
@@ -1804,6 +1815,7 @@ int rewriteConfig(char *path) {
...
@@ -1804,6 +1815,7 @@ int rewriteConfig(char *path) {
rewriteConfigBytesOption
(
state
,
"repl-backlog-ttl"
,
server
.
repl_backlog_time_limit
,
REDIS_DEFAULT_REPL_BACKLOG_TIME_LIMIT
);
rewriteConfigBytesOption
(
state
,
"repl-backlog-ttl"
,
server
.
repl_backlog_time_limit
,
REDIS_DEFAULT_REPL_BACKLOG_TIME_LIMIT
);
rewriteConfigYesNoOption
(
state
,
"repl-disable-tcp-nodelay"
,
server
.
repl_disable_tcp_nodelay
,
REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY
);
rewriteConfigYesNoOption
(
state
,
"repl-disable-tcp-nodelay"
,
server
.
repl_disable_tcp_nodelay
,
REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY
);
rewriteConfigYesNoOption
(
state
,
"repl-diskless-sync"
,
server
.
repl_diskless_sync
,
REDIS_DEFAULT_REPL_DISKLESS_SYNC
);
rewriteConfigYesNoOption
(
state
,
"repl-diskless-sync"
,
server
.
repl_diskless_sync
,
REDIS_DEFAULT_REPL_DISKLESS_SYNC
);
rewriteConfigNumericalOption
(
state
,
"repl-diskless-sync-delay"
,
server
.
repl_diskless_sync_delay
,
REDIS_DEFAULT_REPL_DISKLESS_SYNC_DELAY
);
rewriteConfigNumericalOption
(
state
,
"slave-priority"
,
server
.
slave_priority
,
REDIS_DEFAULT_SLAVE_PRIORITY
);
rewriteConfigNumericalOption
(
state
,
"slave-priority"
,
server
.
slave_priority
,
REDIS_DEFAULT_SLAVE_PRIORITY
);
rewriteConfigNumericalOption
(
state
,
"min-slaves-to-write"
,
server
.
repl_min_slaves_to_write
,
REDIS_DEFAULT_MIN_SLAVES_TO_WRITE
);
rewriteConfigNumericalOption
(
state
,
"min-slaves-to-write"
,
server
.
repl_min_slaves_to_write
,
REDIS_DEFAULT_MIN_SLAVES_TO_WRITE
);
rewriteConfigNumericalOption
(
state
,
"min-slaves-max-lag"
,
server
.
repl_min_slaves_max_lag
,
REDIS_DEFAULT_MIN_SLAVES_MAX_LAG
);
rewriteConfigNumericalOption
(
state
,
"min-slaves-max-lag"
,
server
.
repl_min_slaves_max_lag
,
REDIS_DEFAULT_MIN_SLAVES_MAX_LAG
);
...
...
src/redis.c
View file @
70735243
...
@@ -1481,6 +1481,7 @@ void initServerConfig(void) {
...
@@ -1481,6 +1481,7 @@ void initServerConfig(void) {
server
.
repl_down_since
=
0
;
/* Never connected, repl is down since EVER. */
server
.
repl_down_since
=
0
;
/* Never connected, repl is down since EVER. */
server
.
repl_disable_tcp_nodelay
=
REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY
;
server
.
repl_disable_tcp_nodelay
=
REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY
;
server
.
repl_diskless_sync
=
REDIS_DEFAULT_REPL_DISKLESS_SYNC
;
server
.
repl_diskless_sync
=
REDIS_DEFAULT_REPL_DISKLESS_SYNC
;
server
.
repl_diskless_sync_delay
=
REDIS_DEFAULT_REPL_DISKLESS_SYNC_DELAY
;
server
.
slave_priority
=
REDIS_DEFAULT_SLAVE_PRIORITY
;
server
.
slave_priority
=
REDIS_DEFAULT_SLAVE_PRIORITY
;
server
.
master_repl_offset
=
0
;
server
.
master_repl_offset
=
0
;
...
...
src/redis.h
View file @
70735243
...
@@ -802,6 +802,7 @@ struct redisServer {
...
@@ -802,6 +802,7 @@ struct redisServer {
int
repl_min_slaves_max_lag
;
/* Max lag of <count> slaves to write. */
int
repl_min_slaves_max_lag
;
/* Max lag of <count> slaves to write. */
int
repl_good_slaves_count
;
/* Number of slaves with lag <= max_lag. */
int
repl_good_slaves_count
;
/* Number of slaves with lag <= max_lag. */
int
repl_diskless_sync
;
/* Send RDB to slaves sockets directly. */
int
repl_diskless_sync
;
/* Send RDB to slaves sockets directly. */
int
repl_diskless_sync_delay
;
/* Delay to start a diskless repl BGSAVE. */
/* Replication (slave) */
/* Replication (slave) */
char
*
masterauth
;
/* AUTH with this password with master */
char
*
masterauth
;
/* AUTH with this password with master */
char
*
masterhost
;
/* Hostname of master */
char
*
masterhost
;
/* Hostname of master */
...
...
src/replication.c
View file @
70735243
...
@@ -2034,9 +2034,9 @@ void replicationCron(void) {
...
@@ -2034,9 +2034,9 @@ void replicationCron(void) {
}
}
}
}
if
(
slaves_waiting
&&
max_idle
>
REDIS_DEFAULT_REPL_DISKLESS_SYNC_DELAY
)
if
(
slaves_waiting
&&
max_idle
>
server
.
repl_diskless_sync_delay
)
{
{
/* Start a BGSAVE. Usually with socket target, or with disk target
/
*
Let's start a BGSAVE with disk tar
ge
t
. */
*
if there was a recent socket -> disk config chan
ge. */
if
(
startBgsaveForReplication
()
==
REDIS_OK
)
{
if
(
startBgsaveForReplication
()
==
REDIS_OK
)
{
/* It started! We need to change the state of slaves
/* It started! We need to change the state of slaves
* from WAIT_BGSAVE_START to WAIT_BGSAVE_END. */
* from WAIT_BGSAVE_START to WAIT_BGSAVE_END. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment