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

fix(core): fix race condition in task scheduler #17837

Merged

Conversation

leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Jun 28, 2023

Current Behavior

When tasks are run in parallel, the task orchestrator uses several threads to run them. As tasks complete their execution, the tasks orchestrator requests the task scheduler to schedule the tasks or batches of tasks to run. Since scheduling tasks is an async operation and it's invoked in multiple threads, a race condition can occur scheduling the same tasks multiple times.

Example of a run where this happened: https://staging.nx.app/runs/rfOvLS2DkD

Expected Behavior

The task scheduler should handle scheduling requests in a thread-safe manner. Scheduling requests are chained to ensure they are executed sequentially and the state is stable for each execution.

Related Issue(s)

Fixes #

@leosvelperez leosvelperez self-assigned this Jun 28, 2023
@vercel
Copy link

vercel bot commented Jun 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2023 2:22pm

@nx-cloud
Copy link

nx-cloud bot commented Jun 28, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f9a7107. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@leosvelperez leosvelperez marked this pull request as ready for review June 28, 2023 14:32
@leosvelperez leosvelperez requested a review from a team as a code owner June 28, 2023 14:32
@FrozenPandaz FrozenPandaz merged commit 03ffa42 into nrwl:master Jun 28, 2023
3 checks passed
@leosvelperez leosvelperez deleted the core/fix-task-scheduler-race-condition branch June 28, 2023 16:04
FrozenPandaz pushed a commit that referenced this pull request Jun 28, 2023
@github-actions
Copy link

github-actions bot commented Jul 4, 2023

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants