mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
redis-trib fix: use MIGRATE REPLACE when fixing slots.
This fixes issue #1765.
This commit is contained in:
parent
7f772355f4
commit
56161ca0a4
@ -468,7 +468,7 @@ class RedisTrib
|
|||||||
# Case 1: The slot is in migrating state in one slot, and in
|
# Case 1: The slot is in migrating state in one slot, and in
|
||||||
# importing state in 1 slot. That's trivial to address.
|
# importing state in 1 slot. That's trivial to address.
|
||||||
if migrating.length == 1 && importing.length == 1
|
if migrating.length == 1 && importing.length == 1
|
||||||
move_slot(migrating[0],importing[0],slot,:verbose=>true)
|
move_slot(migrating[0],importing[0],slot,:verbose=>true,:fix=>true)
|
||||||
elsif migrating.length == 1 && importing.length == 0
|
elsif migrating.length == 1 && importing.length == 0
|
||||||
xputs ">>> Setting #{slot} as STABLE"
|
xputs ">>> Setting #{slot} as STABLE"
|
||||||
migrating[0].r.cluster("setslot",slot,"stable")
|
migrating[0].r.cluster("setslot",slot,"stable")
|
||||||
@ -740,7 +740,18 @@ class RedisTrib
|
|||||||
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|
|
keys.each{|key|
|
||||||
source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,15000])
|
begin
|
||||||
|
source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,15000])
|
||||||
|
rescue => e
|
||||||
|
if o[:fix] && e.to_s =~ /BUSYKEY/
|
||||||
|
xputs "*** Target key #{key} exists. Replace it for FIX."
|
||||||
|
source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,15000,:replace])
|
||||||
|
else
|
||||||
|
puts ""
|
||||||
|
xputs "[ERR] #{e}"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
end
|
||||||
print "." if o[:verbose]
|
print "." if o[:verbose]
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user