antirez/redis — pull request #1413 by Dieken (2013-11-29 16:51:54+00:00)
Title: support sticky slave whose slaveof config won't be changed by Redis sentinel

When a Redis slave has slave-priority -1, it becomes a sticky slave,
Redis sentinel neither elects it to become master, nor sends "slaveof"
command to it after new master is elected.

This is to mirror Redis cluster, suppose we have two datacenters,
DC A has 3 Redis instances that are maintained by Redis sentinel,
DC B has 3 Redis instances that synchronize from DC A with fixed
one-one mapping, aka. B_i slaveof A_i where i is 1, 2 or 3. This
wastes cross datacenter bandwidth because three copies of change
are transferred, but is more robust than chaining B2 and B3 to B1.

Without this feature, Redis sentinel will make all slaves synchronize
from single master sooner or later after multiple master elections,
this will consume big bandwidth of the master.

Notice if for some reason we want to revert the mirror relationship,
these steps must be taken to avoid race condition:
1. send "SLAVEOF NO ONE" to B1, send "SLAVEOF " to B2 and B3
2. send "CONFIG SET SLAVE-PRIORITY 100" to B1, B2 and B3
3. start Redis sentinels for B1, B2 and B3
4. stop Redis sentinels for A1, A2 and A3
5. send "CONFIG SET SLAVE-PRIORITY -1" to A1, A2 and A3
6. send "SLAVEOF " to A_i where i is 1, 2 or 3