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
64ad6648
Commit
64ad6648
authored
Nov 14, 2013
by
antirez
Browse files
Sentinel: reconfigure slaves to right master.
parent
3e27d678
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
64ad6648
...
@@ -1596,7 +1596,7 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
...
@@ -1596,7 +1596,7 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
/* A slave turned into a master. We want to force our view and
/* A slave turned into a master. We want to force our view and
* reconfigure as slave, but make sure to wait some time before
* reconfigure as slave, but make sure to wait some time before
* doing this in order to make sure to receive an updated
* doing this in order to make sure to receive an updated
* configuratio via Pub/Sub if any. */
* configuratio
n
via Pub/Sub if any. */
mstime_t wait_time = SENTINEL_PUBLISH_PERIOD*4;
mstime_t wait_time = SENTINEL_PUBLISH_PERIOD*4;
if (!sentinelRedisInstanceNoDownFor(ri,wait_time) ||
if (!sentinelRedisInstanceNoDownFor(ri,wait_time) ||
...
@@ -1620,6 +1620,32 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
...
@@ -1620,6 +1620,32 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
}
}
}
}
/* Handle slaves replicating to a different master address. */
if ((ri->flags & SRI_SLAVE) && !sentinel.tilt &&
(ri->slave_master_port != ri->master->addr->port ||
strcasecmp(ri->slave_master_host,ri->master->addr->ip)))
{
mstime_t wait_time = SENTINEL_PUBLISH_PERIOD*4;
if (!sentinelRedisInstanceNoDownFor(ri,wait_time) ||
mstime() - ri->slave_conf_change_time < wait_time)
return;
/* Make sure the master is sane before reconfiguring this instance
* into a slave. */
if (ri->master->flags & SRI_MASTER &&
ri->master->role_reported == SRI_MASTER &&
(ri->master->flags & (SRI_S_DOWN|SRI_O_DOWN)) == 0 &&
(mstime() - ri->master->info_refresh) < SENTINEL_INFO_PERIOD*2)
{
int retval = sentinelSendSlaveOf(ri,
ri->master->addr->ip,
ri->master->addr->port);
if (retval == REDIS_OK)
sentinelEvent(REDIS_NOTICE,"+fix-slave-config",ri,"%@");
}
}
/* None of the following conditions are processed when in tilt mode, so
/* None of the following conditions are processed when in tilt mode, so
* return asap. */
* return asap. */
if (sentinel.tilt) return;
if (sentinel.tilt) return;
...
...
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