message: fix map erase
diff: @@ -738,11 +738,13 @@ int32_t Balancer::giveupLeaders(HostParts& leaderParts,
  int32_t taskCount = 0;
  auto& sourceLeaders = leaderParts[source];
  size_t maxLoad = hostBounds_[source].second;
  +
  // host will try to transfer the extra leaders to other peers
  - for (auto it = sourceLeaders.begin(); it != sourceLeaders.end(); it++) {
  + for (auto it = sourceLeaders.begin(); it != sourceLeaders.end();) {
  // find the leader of partId
  auto partId = *it;
  const auto& targets = peersMap[partId];
  + bool isErase = false;
  // leader should move to the peer with lowest loading
  auto target = std::min_element(targets.begin(), targets.end(),
  @@ -752,7 +754,9 @@ int32_t Balancer::giveupLeaders(HostParts& leaderParts,
  }
  return leaderParts[l].size() < leaderParts[r].size();
  });
  +
  // If peer can accept this partition leader, than host will transfer to the peer
  + if (target != targets.end()) {
  auto& targetLeaders = leaderParts[*target];
  int32_t targetLeaderSize = targetLeaders.size();
  if (targetLeaderSize < hostBounds_[*target].second) {
  @@ -764,6 +768,8 @@ int32_t Balancer::giveupLeaders(HostParts& leaderParts,
  << " from " << source.host << ":" << source.port
  << " to " << target->host << ":" << target->port;
  ++taskCount;
  + isErase = true;
  + }
  }
  // if host has enough leader, just return
  @@ -771,6 +777,10 @@ int32_t Balancer::giveupLeaders(HostParts& leaderParts,
  LOG(INFO) << "Host: " << source << "'s leader reach " << maxLoad;
  break;
  }
  +
  + if (!isErase) {
  + ++it;
  + }
  }
  return taskCount;
  }
  