Skip to content

Static content deploy - Randomly css files not generated #22880

Closed
@ihor-sviziev

Description

@ihor-sviziev

Preconditions (*)

  1. Magento 2.3.x(2.3-develop too)
  2. Configured Build system according to technical details.
  3. Create own theme that extends from Magento/luma
  4. Magento mode is default OR developer

Steps to reproduce (*)

  1. Run php bin/magento setup:static-content:deploy -f -j $(nproc) (-j 8 in my case) with 6 different locales on build system

Expected result (*)

  1. We should NOT have any errors/exceptions during SCD

Actual result (*)

  1. Randomly we have following issue (sometimes from 4-5th time):
  • Some CSS files are missing in pub/static directory
  • Exception somewhere in the middle of SCD

image

This happening really randomly, sometimes with Magento/luma theme, sometimes with our own
File with errors:
errors.txt

Technical details

During SCD - it tries to compile LESS -> CSS files. During working on it - it tries to create lock, add some files and then unlock:

$this->lockerProcess->lockProcess($this->lockName);
$module = $chain->getAsset()->getModule();
/** @var FallbackContext $context */
$context = $chain->getAsset()->getContext();
$chain->setContent($this->processContent($path, $content, $module, $context));
} finally {
$this->lockerProcess->unlockProcess();

Details of these locks:

public function lockProcess($lockName)
{
if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
return;
}
$this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->lockFilePath = $this->getFilePath($lockName);
while ($this->isProcessLocked()) {
usleep(1000);
}
$this->tmpDirectory->writeFile($this->lockFilePath, time());
}

and

public function unlockProcess()
{
if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
return;
}
$this->tmpDirectory->delete($this->lockFilePath);
}

As you can see above - locking process doesn't work in production mode, but static contend deploy we're running when env.php file is not present, so by fallback it runs in "default" magento mode.

Also that's not expected to have some lock when we're running SCD in parallel, it might significantly slow down this process.

This issue was discovered during testing #22607

Metadata

Metadata

Assignees

Labels

Component: Framework/LocaleComponent: ThemeFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions