Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes regarding concurrency #475

Merged
merged 3 commits into from
Nov 21, 2023
Merged

Fixes regarding concurrency #475

merged 3 commits into from
Nov 21, 2023

Conversation

hoh
Copy link
Member

@hoh hoh commented Nov 21, 2023

This branch adds 3 fixes regarding the concurrency of launching the same VM multiple times
in a short period of time, before the setup of the other instances has finished.

  • Fix: Ordering issue in starting persistent VM
  • Fix: Two executions for the same VM could be prepared in parallel
  • Fix: A VM could be prepared in parallel

@github-actions github-actions bot added the BLUE This PR is simple and straightforward. label Nov 21, 2023
Copy link

  • Added a lock to prevent concurrent preparation of the same VM execution.
  • Improved the create_a_vm function by returning an existing VM execution if it already exists in the pool.

@hoh hoh requested a review from olethanh November 21, 2023 11:36
Cancelling the expiration must be done after the execution becomes ready.

Solution: First wait for the execution to become ready before marking it as persistent and cancelling its expiration.
Problem: Checking the existence of the execution in one corouting and creating it in another could lead to an inconsistent state where two executions are starting for the same VM.

Solution: Check for the existence of the execution or register it on the pool inside the same coroutine, without any `await` between
Problem: The method `prepare()` of a VM could be launched multiple times in parallel.

Solution: Use a lock and skip the preparation if it has already been done.
@hoh hoh merged commit 68b6bf6 into main Nov 21, 2023
15 of 18 checks passed
@hoh hoh added this to the 0.3.1 Bugfix release milestone Nov 24, 2023
@Psycojoker Psycojoker deleted the hoh-fix-concurrency branch July 24, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLUE This PR is simple and straightforward.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants