diff options
author | antirez <antirez@gmail.com> | 2015-10-09 16:15:53 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-10-15 13:06:31 +0200 |
commit | 568c83dda75e6111b211eedeecee0e24043866d0 (patch) | |
tree | 6f3c7bedc0606218444c182a01d3cb3b258f6a64 | |
parent | 892b1c3c58a409580fe9cd2fafe065d983e68382 (diff) | |
download | redis-568c83dda75e6111b211eedeecee0e24043866d0.tar.gz |
Cluster: redis-trib fix, coverage for migrating=1 case.
Kinda related to #2770.
-rwxr-xr-x | src/redis-trib.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb index 6002e4caa..8e07aa22a 100755 --- a/src/redis-trib.rb +++ b/src/redis-trib.rb @@ -496,6 +496,10 @@ class RedisTrib # importing state in 1 slot. That's trivial to address. if migrating.length == 1 && importing.length == 1 move_slot(migrating[0],importing[0],slot,:verbose=>true,:fix=>true) + # Case 2: There are multiple nodes that claim the slot as importing, + # they probably got keys about the slot after a restart so opened + # the slot. In this case we just move all the keys to the owner + # according to the configuration. elsif migrating.length == 0 && importing.length > 0 xputs ">>> Moving all the #{slot} slot keys to its owner #{owner}" importing.each {|node| @@ -504,8 +508,14 @@ class RedisTrib xputs ">>> Setting #{slot} as STABLE in #{node}" node.r.cluster("setslot",slot,"stable") } + # Case 3: There are no slots claiming to be in importing state, but + # there is a migrating node that actually don't have any key. We + # can just close the slot, probably a reshard interrupted in the middle. + elsif importing.length == 0 && migrating.length == 1 && + migrating[0].r.cluster("getkeysinslot",slot,10).length == 0 + migrating[0].r.cluster("setslot",slot,"stable") else - xputs "[ERR] Sorry, Redis-trib can't fix this slot yet (work in progress)" + xputs "[ERR] Sorry, Redis-trib can't fix this slot yet (work in progress). Slot is set as migrating in #{migrating.join(",")}, as importing in #{importing.join(",")}, owner is #{owner}" end end @@ -812,7 +822,7 @@ class RedisTrib 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." + xputs "*** Target key #{key} exists. Replacing it for FIX." source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,15000,:replace]) else puts "" |