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
3a374b05
Commit
3a374b05
authored
Nov 18, 2013
by
antirez
Browse files
Sentinel: failover abort function simplified.
parent
e0750acf
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
3a374b05
...
@@ -1155,7 +1155,7 @@ int sentinelResetMastersByPattern(char *pattern, int flags) {
...
@@ -1155,7 +1155,7 @@ int sentinelResetMastersByPattern(char *pattern, int flags) {
/* Reset the specified master with sentinelResetMaster(), and also change
/* Reset the specified master with sentinelResetMaster(), and also change
* the ip:port address, but take the name of the instance unmodified.
* the ip:port address, but take the name of the instance unmodified.
*
*
* This is used to handle the +switch-master
and +redirect-to-master
event
s
.
* This is used to handle the +switch-master event.
*
*
* The function returns REDIS_ERR if the address can't be resolved for some
* The function returns REDIS_ERR if the address can't be resolved for some
* reason. Otherwise REDIS_OK is returned. */
* reason. Otherwise REDIS_OK is returned. */
...
@@ -3061,40 +3061,15 @@ void sentinelFailoverStateMachine(sentinelRedisInstance *ri) {
...
@@ -3061,40 +3061,15 @@ void sentinelFailoverStateMachine(sentinelRedisInstance *ri) {
*
*
* This function can only be called before the promoted slave acknowledged
* This function can only be called before the promoted slave acknowledged
* the slave -> master switch. Otherwise the failover can't be aborted and
* the slave -> master switch. Otherwise the failover can't be aborted and
* will reach its end.
* will reach its end (possibly by timeout). */
*
* If there is a promoted slave and we already got acknowledge of the
* slave -> master switch, we clear our flags and redirect to the
* new master. Eventually the config will be propagated if it is the one
* with the greater config epoch for this master.
*
* Otherwise if we still did not received the acknowledgement from the
* promoted slave, or there is no promoted slave at all, we just clear the
* failover-in-progress state as there is nothing to do (if the promoted
* slave for some reason actually received our "SLAVEOF NO ONE" command
* even if we did not received the ACK, it will be reverted to slave again
* by one of the Sentinels). */
void sentinelAbortFailover(sentinelRedisInstance *ri) {
void sentinelAbortFailover(sentinelRedisInstance *ri) {
dictIterator *di;
dictEntry *de;
redisAssert(ri->flags & SRI_FAILOVER_IN_PROGRESS);
redisAssert(ri->flags & SRI_FAILOVER_IN_PROGRESS);
redisAssert(ri->failover_state <= SENTINEL_FAILOVER_STATE_WAIT_PROMOTION);
redisAssert(ri->failover_state <= SENTINEL_FAILOVER_STATE_WAIT_PROMOTION);
/* Clear failover related flags from slaves. */
di = dictGetIterator(ri->slaves);
while((de = dictNext(di)) != NULL) {
sentinelRedisInstance *slave = dictGetVal(de);
slave->flags &= ~(SRI_RECONF_SENT|SRI_RECONF_INPROG|SRI_RECONF_DONE);
}
dictReleaseIterator(di);
ri->flags &= ~(SRI_FAILOVER_IN_PROGRESS|SRI_FORCE_FAILOVER);
ri->flags &= ~(SRI_FAILOVER_IN_PROGRESS|SRI_FORCE_FAILOVER);
ri->failover_state = SENTINEL_FAILOVER_STATE_NONE;
ri->failover_state = SENTINEL_FAILOVER_STATE_NONE;
ri->failover_state_change_time = mstime();
ri->failover_state_change_time = mstime();
if (ri->promoted_slave) {
if (ri->promoted_slave) {
sentinelCallClientReconfScript(ri,SENTINEL_LEADER,"abort",
ri->promoted_slave->addr,ri->addr);
ri->promoted_slave->flags &= ~SRI_PROMOTED;
ri->promoted_slave->flags &= ~SRI_PROMOTED;
ri->promoted_slave = NULL;
ri->promoted_slave = NULL;
}
}
...
...
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