Skip to content

Commit

Permalink
Fix #283. Dropping shard and restart in cluster causes panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldix committed Feb 27, 2014
1 parent e314813 commit 115d5d1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/cluster/cluster_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 115d5d1

Please sign in to comment.