Skip to content

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

Open
wants to merge 6 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions app/code/Magento/Deploy/Process/Queue.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2017 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand All @@ -24,12 +24,12 @@ class Queue
/**
* Default max amount of processes
*/
const DEFAULT_MAX_PROCESSES_AMOUNT = 4;
public const DEFAULT_MAX_PROCESSES_AMOUNT = 4;

/**
* Default max execution time
*/
const DEFAULT_MAX_EXEC_TIME = 900;
public const DEFAULT_MAX_EXEC_TIME = 900;

/**
* @var array
Expand Down Expand Up @@ -263,6 +263,15 @@ private function executePackage(Package $package, string $name, array &$packages
&& !$this->isDeployed($package)
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))
) {
//Prevents duplicate execution of a theme package by checking if it has already been scheduled.
if (!isset($packages[$name])) {
$this->logger->debug(sprintf(
'Preventing duplicate execution of package as it is in progress: %s (pid: %s)',
$package->getPath(),
$this->getPid($package)
));
return;
}
unset($packages[$name]);
$this->execute($package);
}
Expand Down