Fix #283. Dropping shard and restart in cluster causes panic.

pull/290/head
Paul Dix 2014-02-27 10:33:18 -05:00
parent e314813e7e
commit 115d5d16b8
1 changed files with 14 additions and 0 deletions

View File

@ -970,6 +970,20 @@ func (self *ClusterConfiguration) updateOrRemoveShard(shardId uint32, serverIds
self.shardsByIdLock.RLock()
shard := self.shardsById[shardId]
self.shardsByIdLock.RUnlock()
// may not be in the map, try to get it from the list
if shard == nil {
for _, s := range self.GetAllShards() {
if s.id == shardId {
shard = s
break
}
}
}
if shard == nil {
log.Error("Attempted to remove shard %d, which we couldn't find. %d shards currently loaded.", shardId, len(self.GetAllShards()))
}
if len(shard.serverIds) == len(serverIds) {
self.removeShard(shardId)
return