-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix concurrency issue in static content deploy #39954
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
base: 2.4-develop
Are you sure you want to change the base?
Conversation
Hi @convenient. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE |
@magento run all tests |
The static analysis is failing with the following. Can I please have a recommendation for the correct approach here, given that none of these issues relate to my code change.
|
Every file touched in a PR should adhere to the latest static test checks, even if it's not code you touched, annoying, but it is what it is I'm afraid.
|
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a concurrency bug during static content deployment, ensuring that the same theme package is not handled by multiple concurrent processes.
- Prevents duplicate execution of a theme package by checking if it has already been scheduled.
- Adds a debug log to indicate when duplicate execution is prevented.
Comments suppressed due to low confidence (1)
app/code/Magento/Deploy/Process/Queue.php:266
- Add a brief comment explaining that the absence of the package in the $packages array indicates it is already in progress, to aid future maintainers in understanding why duplicate execution is being prevented.
if (!isset($packages[$name])) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @convenient,
Thank you so much for the contribution! Looks good
Could you please fix static test failures as described in #39954 (comment)
@magento run all tests |
@convenient & @ihor-sviziev I have fixed the static test cases also added the comment above the if statement. The other failing test cases seems flaky to me. Could you please review the changes ? Moving it back to pending review. Thanks! |
@magento run Unit Tests, Functional Tests B2B, Functional Tests CE, Functional Tests EE |
Summary
This fixes a bug in which multiple concurrent processes spin up to handle the same theme package, depending on how the themes are defined with their parents.
We saw a lot of issues like
We also saw less compilation intermittently failing to generate complete
styles-m.css
andstyles-l.css
files, as multiple processes were fighting and doing work on the same file at the same time. This cause the frontend to be deployed in a broken manner which needed a redeploy to solve.For affected setups this may also improve the performance of this process, by the idea that we have a process no longer doing duplicated work.
To reproduce
Reproduce
Clone https://github.com/convenient/magento-bug-reproduction-static-content-concurrency then run
composer install
, you can now generate static content.Without the bugfix we can see multiple executions of the same package, see that
frontend/Custom/ztheme/default
is executed multiple timesWith the bugfix we can see each is only executed once
Verification
I have used this fix on production for over a year without any issues. But we can also double check on the example reproduction repository provided above.
Get a baseline
Apply the bugfix then do the following
See that all files (that matter) were generated the same
Contribution checklist (*)