Skip to content

[Core] Cancel lease requests before returning a PG bundle - #45919

Merged
jjyao merged 9 commits into
ray-project:masterfrom
jjyao:jjyao/pgg
Jun 16, 2024
Merged

jjyao merged 9 commits into
ray-project:masterfrom
jjyao:jjyao/pgg

Conversation

@jjyao

@jjyao jjyao commented Jun 13, 2024 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

To successfully return a PG bundle (CancelResourceReserve and ReleaseUnusedBundles), the bundle resource needs to be completely free (i.e. total == available). To make sure that, raylet will first destroy leased workers that are currently using the PG bundle resources so that these bundle resources can be freed. However this alone cannot guarantee that all bundle resources will be freed since a lease request that's popping worker also already acquires the bundle resources so we need to cancel these lease requests as well to free the bundle resources.

After this PR, we don't need the retry in #42942.

Related issue number

Closes #45642

Checks

Comment on lines +686 to +695
// Cancel lease requests related to unused bundles
cluster_task_manager_->CancelTasks(
[&](const RayTask &task) {
const auto bundle_id = task.GetTaskSpecification().PlacementGroupBundleId();
return !bundle_id.first.IsNil() && 0 == in_use_bundles.count(bundle_id);
},
rpc::RequestWorkerLeaseReply::SCHEDULING_CANCELLED_INTENDED,
"The task is cancelled because it uses placement group bundles that are not "
"registered to GCS. It can happen upon GCS restart.");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual fix.

Comment on lines +1902 to +1910
// Cancel lease requests related to the placement group to be removed.
cluster_task_manager_->CancelTasks(
[&](const RayTask &task) {
const auto bundle_id = task.GetTaskSpecification().PlacementGroupBundleId();
return bundle_id.first == bundle_spec.PlacementGroupId();
},
rpc::RequestWorkerLeaseReply::SCHEDULING_CANCELLED_PLACEMENT_GROUP_REMOVED,
"");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual fix.

@jjyao jjyao added the go add ONLY when ready to merge, run all tests label Jun 13, 2024
Signed-off-by: Jiajun Yao <[email protected]>
@jjyao
jjyao marked this pull request as ready for review June 13, 2024 17:19
@jjyao
jjyao requested a review from a team as a code owner June 13, 2024 17:19
@rynewang

Copy link
Copy Markdown
Contributor

Side comment: we found multiple similar cases, in that when we want to kill all workers under a predicate (e.g. job died, root detached actor died, pg died, ...), we have to do it multiple places:

  • NodeManager::leased_workers_
  • WorkerPool::PopWorkerCallbackInternal
  • WorkerPool::InvokePopWorkerCallbackForProcess
  • WorkerPool::KillIdleWorker

I wonder if we can have a unified mechanism to do the killing for all...

thread.join();

RayConfig::instance().initialize(promise.get_future().get());
ray::asio::testing::init();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure we can set testing_asio_delay_us env var through _system_configs

Comment thread src/ray/raylet/local_task_manager.cc Resolved
Comment thread src/ray/raylet/local_task_manager.cc Resolved
jjyao added 4 commits June 13, 2024 13:07
@jjyao
jjyao requested a review from rynewang June 14, 2024 18:59
Comment thread src/ray/raylet/local_task_manager.cc Resolved
Comment thread src/ray/util/container_util.h Resolved
@jjyao
jjyao enabled auto-merge (squash) June 16, 2024 04:22
@jjyao
jjyao merged commit f0f52fa into ray-project:master Jun 16, 2024
@jjyao
jjyao deleted the jjyao/pgg branch June 17, 2024 02:26
can-anyscale added a commit that referenced this pull request Jun 17, 2024
@can-anyscale

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Raylet check failed: placement_group_resource_manager.cc:29: Check failed: ReturnBundle(*iter->second).ok()

4 participants