mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
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:
parent
4e252e4c09
commit
f0b168e894
@ -818,22 +818,20 @@ class RedisTrib
|
|||||||
while true
|
while true
|
||||||
keys = source.r.cluster("getkeysinslot",slot,10)
|
keys = source.r.cluster("getkeysinslot",slot,10)
|
||||||
break if keys.length == 0
|
break if keys.length == 0
|
||||||
keys.each{|key|
|
|
||||||
begin
|
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
|
rescue => e
|
||||||
if o[:fix] && e.to_s =~ /BUSYKEY/
|
if o[:fix] && e.to_s =~ /BUSYKEY/
|
||||||
xputs "*** Target key #{key} exists. Replacing it for FIX."
|
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
|
else
|
||||||
puts ""
|
puts ""
|
||||||
xputs "[ERR] #{e}"
|
xputs "[ERR] #{e}"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print "." if o[:verbose]
|
print "."*keys.length if o[:verbose]
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
puts
|
puts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user