Cluster: redis-trib: use variadic MIGRATE.

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
This commit is contained in:
antirez 2015-12-11 18:10:40 +01:00
parent 4e252e4c09
commit f0b168e894

View File

@ -818,22 +818,20 @@ class RedisTrib
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])
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],key,0,@timeout,:replace])
source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:replace,:keys,*keys])
else
puts ""
xputs "[ERR] #{e}"
exit 1
end
end
print "." if o[:verbose]
print "."*keys.length if o[:verbose]
STDOUT.flush
}
end
puts