Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
54c447be
Commit
54c447be
authored
Nov 12, 2013
by
antirez
Browse files
Sentinel: wait some time between failover attempts.
parent
ab4b2ec8
Changes
1
Show whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
54c447be
...
...
@@ -177,7 +177,7 @@ typedef struct sentinelRedisInstance {
uint64_t
failover_epoch
;
/* Epoch of the currently started failover. */
int
failover_state
;
/* See SENTINEL_FAILOVER_STATE_* defines. */
mstime_t
failover_state_change_time
;
mstime_t
failover_start_time
;
/*
When to start to failover if leader
. */
mstime_t
failover_start_time
;
/*
Last failover attempt start time
. */
mstime_t
failover_timeout
;
/* Max time to refresh failover state. */
struct
sentinelRedisInstance
*
promoted_slave
;
/* Promoted slave instance. */
/* Scripts executed to notify admin or reconfigure clients: when they
...
...
@@ -2411,7 +2411,7 @@ char *sentinelVoteLeader(sentinelRedisInstance *master, uint64_t req_epoch, char
}
*
leader_epoch
=
master
->
leader_epoch
;
return
master
->
leader
;
return
master
->
leader
?
sdsnew
(
master
->
leader
)
:
NULL
;
}
struct
sentinelLeader
{
...
...
@@ -2540,6 +2540,7 @@ void sentinelStartFailover(sentinelRedisInstance *master) {
master
->
flags
|=
SRI_FAILOVER_IN_PROGRESS
;
master
->
failover_epoch
=
++
sentinel
.
current_epoch
;
sentinelEvent
(
REDIS_WARNING
,
"+failover-triggered"
,
master
,
"%@"
);
master
->
failover_start_time
=
mstime
();
master
->
failover_state_change_time
=
mstime
();
}
...
...
@@ -2559,6 +2560,10 @@ void sentinelStartFailoverIfNeeded(sentinelRedisInstance *master) {
/* Failover already in progress? */
if
(
master
->
flags
&
SRI_FAILOVER_IN_PROGRESS
)
return
;
/* Last failover attempt started too little time ago? */
if
(
mstime
()
-
master
->
failover_start_time
<
SENTINEL_PUBLISH_PERIOD
*
4
)
return
;
sentinelStartFailover
(
master
);
}
...
...
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