When a range (1) is assigned to a node (a), and we want to split it into two separate ranges (2, 3) assigned to different nodes (b, c), we split it.
- Prepare
- Prepare(b, 2)
- Prepare(c, 3)
- Deactivate(a, 1)
- Activate
- Activate(b, 2)
- Activate(c, 3)
- Drop(a, 1)
If any of the Prepare commands in step 1 fail, just destroy the failed placement(s) and try again on some other node. The predecessor range is still active, so there is no particular harm in waiting while we try again.
PreparePrepare(b, 2)Prepare(c, 3)
- Prepare (retry)
- Prepare(d, 2)
- Prepare(e, 3)
or
PreparePrepare(b, 2)- Prepare(c, 3)
- Prepare (retry)
- Prepare(d, 2)
or
Prepare- Prepare(b, 2)
Prepare(c, 3)
- Prepare (retry)
- Prepare(d, 3)
Note that cancellation isn't currently part of the Rangelet API (because the command methods don't include a context param), so we have to dumbly wait until both sides complete their Prepare before we can proceed, even if one fails fast. Not a huge deal, but pointless work.
If step 2 fails -- the source placement failed to Deactivate -- just retry forever (and probably alert an operator). This isn't an emergency (the source placement is still active), but indicates that something is quite broken.
- Prepare
- Prepare(b, 2)
- Prepare(c, 3)
Deactivate(a, 1)- Deactivate(a, 1) (retry)
If step 3 fails, deactivate any destination placements which became active (i.e. the ones which didn't fail), reactivate the source placement, drop the placements which failed to activate, and retry their placement.
- Prepare
- Prepare(b, 2)
- Prepare(c, 3)
- Deactivate(a, 1)
ActivateActivate(b, 2)Activate(c, 3)
- Activate(a, 1)
- Drop
- Drop(b, 2)
- Drop(c, 3)
- Prepare (retry)
- Prepare(d, 2)
- Prepare(e, 3)
or
- Prepare
- Prepare(b, 2)
- Prepare(c, 3)
- Deactivate(a, 1)
ActivateActivate(b, 2)- Activate(c, 3)
- Deactivate
- Deactivate(c, 3)
- Activate(a, 1)
- Drop
- Drop(b, 2)
- Prepare (retry)
- Prepare(d, 2)
or
- Prepare
- Prepare(b, 2)
- Prepare(c, 3)
- Deactivate(a, 1)
Activate- Activate(b, 2)
Activate(c, 3)
- Deactivate
- Deactivate(b, 2)
- Activate(a, 1)
- Drop
- Drop(c, 3)
- Prepare (retry)
- Prepare(c, 3)
This one is probably the most complex to recover from.
If step 4 fails, do nothing but keep trying forever:
- Prepare
- Prepare(b, 2)
- Prepare(c, 3)
- Deactivate(a, 1)
- Activate
- Activate(b, 2)
- Activate(c, 3)
Drop(a, 1)