summaryrefslogtreecommitdiff
path: root/src/redis-trib.rb
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-10-13 15:16:03 +0200
committerantirez <antirez@gmail.com>2011-10-13 15:16:03 +0200
commitdd9ad570622cc7a164173d4cb6103655482a9b9f (patch)
treedddb51585132673f010b62f3fae1cb128543a600 /src/redis-trib.rb
parent2b9ce0192ef93a6b01009d381202833e10dc7e4a (diff)
downloadredis-dd9ad570622cc7a164173d4cb6103655482a9b9f.tar.gz
redis-trib: fix for a slot allocation bug.
Diffstat (limited to 'src/redis-trib.rb')
-rwxr-xr-xsrc/redis-trib.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index 8768e544e..fa0e8c6dd 100755
--- a/src/redis-trib.rb
+++ b/src/redis-trib.rb
@@ -319,10 +319,11 @@ class RedisTrib
# divisibility. Like we have 3 nodes and need to get 10 slots, we take
# 4 from the first, and 3 from the rest. So the biggest is always the first.
sources = sources.sort{|a,b| b.slots.length <=> a.slots.length}
+ source_tot_slots = sources.inject {|a,b| a.slots.length+b.slots.length}
sources.each_with_index{|s,i|
# Every node will provide a number of slots proportional to the
# slots it has assigned.
- n = (numslots.to_f/4096*s.slots.length)
+ n = (numslots.to_f/source_tot_slots*s.slots.length)
if i == 0
n = n.ceil
else