From be7938ee09df9314ad934dac06b546920111570a Mon Sep 17 00:00:00 2001 From: fangfengbin <869218239a@zju.edu.cn> Date: Tue, 24 Nov 2020 16:57:17 +0800 Subject: [PATCH] [PlacementGroup]Fix AddBundleLocations bug (#12330) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 灵洵 --- .../gcs_server/gcs_placement_group_scheduler.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ray/gcs/gcs_server/gcs_placement_group_scheduler.cc b/src/ray/gcs/gcs_server/gcs_placement_group_scheduler.cc index 5dc85a047..902c391f5 100644 --- a/src/ray/gcs/gcs_server/gcs_placement_group_scheduler.cc +++ b/src/ray/gcs/gcs_server/gcs_placement_group_scheduler.cc @@ -274,7 +274,7 @@ void GcsPlacementGroupScheduler::DestroyPlacementGroupBundleResourcesIfExists( } // Now let's see if there are leasing bundles. There could be leasing bundles and - // committed bundles at the same time if plaement groups are reshceduling. + // committed bundles at the same time if placement groups are rescheduling. auto it = placement_group_leasing_in_progress_.find(placement_group_id); if (it != placement_group_leasing_in_progress_.end()) { const auto &leasing_context = it->second; @@ -598,7 +598,17 @@ void GcsPlacementGroupScheduler::ReleaseUnusedBundles( void BundleLocationIndex::AddBundleLocations( const PlacementGroupID &placement_group_id, std::shared_ptr bundle_locations) { - placement_group_to_bundle_locations_.emplace(placement_group_id, bundle_locations); + // Update `placement_group_to_bundle_locations_`. + // The placement group may be scheduled several times to succeed, so we need to merge + // `bundle_locations` instead of covering it directly. + auto iter = placement_group_to_bundle_locations_.find(placement_group_id); + if (iter == placement_group_to_bundle_locations_.end()) { + placement_group_to_bundle_locations_.emplace(placement_group_id, bundle_locations); + } else { + iter->second->insert(bundle_locations->begin(), bundle_locations->end()); + } + + // Update `node_to_leased_bundles_`. for (auto iter : *bundle_locations) { const auto &node_id = iter.second.first; if (!node_to_leased_bundles_.contains(node_id)) {