Skip to content

Commit

Permalink
fix: MOVED slot redirection handler (#749)
Browse files Browse the repository at this point in the history
The moved handler must update the targetSlot before tryConnection call to correctly choose the node that owns the slot.
  • Loading branch information
vflopes authored and luin committed Nov 24, 2018
1 parent 416f533 commit bba418f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class Cluster extends EventEmitter {
}
}

const targetSlot = node ? node.slot : command.getSlot()
let targetSlot = node ? node.slot : command.getSlot()
const ttl = {}
const _this = this
if (!node && !command.__is_reject_overwritten) {
Expand All @@ -443,6 +443,7 @@ class Cluster extends EventEmitter {
_this.handleError(err, ttl, {
moved: function (slot, key) {
debug('command %s is moved to %s', command.name, key)
targetSlot = Number(slot)
if (_this.slots[slot]) {
_this.slots[slot][0] = key
} else {
Expand Down

0 comments on commit bba418f

Please sign in to comment.