support sticky slave whose slaveof config won't be changed by Redis sentinel #1413

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant
@Dieken
Contributor

Dieken commented Nov 29, 2013

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 B1_addr B1_port" 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 B_i_addr B_i_port" to A_i where i is 1, 2 or 3

@Dieken

This comment has been minimized.

Show comment Hide comment
@Dieken

Dieken Nov 29, 2013

Contributor
Contributor

Dieken commented Nov 29, 2013

support sticky slave whose slaveof config won't be changed by Redis s…
…entinel

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 <B1_addr> <B1_port>" 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 <B_i_addr> <B_i_port>" to A_i where i is 1, 2 or 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment