Skip to content

Commit

Permalink
Cluster: redis-trib: use variadic MIGRATE.
Browse files Browse the repository at this point in the history
We use the new variadic/pipelined MIGRATE for faster migration.
Testing is not easy because to see the time it takes for a slot to be
migrated requires a very large data set, but even with all the overhead
of migrating multiple slots and to setup them properly, what used to
take 4 seconds (1 million keys, 200 slots migrated) is now 1.6 which is
a good improvement. However the improvement can be a lot larger if:

1. We use large datasets where a single slot has many keys.
2. By moving more than 10 keys per iteration, making this configurable,
   which is planned.

Close #2710
Close #2711
  • Loading branch information
antirez committed Dec 13, 2015
1 parent 00353f9 commit 87615a8
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/redis-trib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -818,22 +818,20 @@ def move_slot(source,target,slot,o={})
while true
keys = source.r.cluster("getkeysinslot",slot,10)
break if keys.length == 0
keys.each{|key|
begin
source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,@timeout])
rescue => e
if o[:fix] && e.to_s =~ /BUSYKEY/
xputs "*** Target key #{key} exists. Replacing it for FIX."
source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,@timeout,:replace])
else
puts ""
xputs "[ERR] #{e}"
exit 1
end
begin
source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:keys,*keys])
rescue => e
if o[:fix] && e.to_s =~ /BUSYKEY/
xputs "*** Target key #{key} exists. Replacing it for FIX."
source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:replace,:keys,*keys])
else
puts ""
xputs "[ERR] #{e}"
exit 1
end
print "." if o[:verbose]
STDOUT.flush
}
end
print "."*keys.length if o[:verbose]
STDOUT.flush
end

puts
Expand Down

0 comments on commit 87615a8

Please sign in to comment.