Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 18 additions & 10 deletions patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,14 @@
"Unlock locale editing when SCD on demand is enabled": {
"2.2.0 - 2.2.5": "MAGECLOUD-2159__unlock_locale_editing_when_scd_on_demand__2.2.0.patch"
},
"Allow DB dumps done with the support module to complete": {
"2.2.0 - 2.2.5": "MAGECLOUD-2033__prevent_deadlock_during_db_dump__2.2.0.patch"
},
"Write Logs for Failed Process of Generating Factories in Extensions": {
"2.2.0 - 2.2.5": "MAGECLOUD-2209__write_logs_for_failed_process_of_generating_factories_in_extensions__2.2.0.patch"
},
"Fix Problems with Consumer Runners on Cloud Clusters": {
"2.2.0 - 2.2.3": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.0.patch",
"2.2.4": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.4.patch",
"2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5.patch",
"2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6.patch",
"2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7.patch",
"2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8.patch",
"2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ce.patch",
"2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ce.patch",
"2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ce.patch",
"2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ce.patch",
"2.3.0": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.0.patch",
">=2.3.1 <2.3.3": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.1.patch"
},
Expand Down Expand Up @@ -186,7 +181,6 @@
">=2.3.0 <2.3.3": "MAGECLOUD-3806__error_code_fix_for_setup_upgrade__2.3.0.patch"
},
"Re-work consumers to terminate as soon as there is nothing left to process": {
"2.2.0 - 2.3.1": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.2.0.patch",
">=2.3.2 <2.3.4": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.3.2.patch"
},
"Backward Compatibility of new Mail Interfaces": {
Expand Down Expand Up @@ -302,6 +296,20 @@
"2.3.2": "PB-320__fix_pagebuilder_module__2.3.2.patch",
">=2.3.2-p1 <2.3.3": "PB-322__fix_pagebuilder_module__2.3.2-p1.patch",
"2.3.3": "PB-323__fix_pagebuilder_module__2.3.3.patch"
},
"Allow DB dumps done with the support module to complete": {
"2.2.0 - 2.2.5": "MAGECLOUD-2033__prevent_deadlock_during_db_dump__2.2.0.patch"
},
"Fix Problems with Consumer Runners on Cloud Clusters": {
"2.2.0 - 2.2.3": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.0.patch",
"2.2.4": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.4.patch",
"2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ee.patch",
"2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ee.patch",
"2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ee.patch",
"2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ee.patch"
},
"Re-work consumers to terminate as soon as there is nothing left to process": {
">=2.2.0 <2.3.2": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.2.0.patch"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php
--- a/vendor/magento/framework/Lock/Backend/Database.php
+++ b/vendor/magento/framework/Lock/Backend/Database.php
@@ -3,8 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
declare(strict_types=1);
+
namespace Magento\Framework\Lock\Backend;

use Magento\Framework\App\DeploymentConfig;
@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Phrase;

+/**
+ * Implementation of the lock manager on the basis of MySQL.
+ */
class Database implements \Magento\Framework\Lock\LockManagerInterface
{
- /** @var ResourceConnection */
+ /**
+ * Max time for lock is 1 week
+ *
+ * MariaDB does not support negative timeout value to get infinite timeout,
+ * so we set 1 week for lock timeout
+ */
+ const MAX_LOCK_TIME = 604800;
+
+ /**
+ * @var ResourceConnection
+ */
private $resource;

- /** @var DeploymentConfig */
+ /**
+ * @var DeploymentConfig
+ */
private $deploymentConfig;

- /** @var string Lock prefix */
+ /**
+ * @var string Lock prefix
+ */
private $prefix;

- /** @var string|false Holds current lock name if set, otherwise false */
+ /**
+ * @var string|false Holds current lock name if set, otherwise false
+ */
private $currentLock = false;

+ /**
+ * @param ResourceConnection $resource
+ * @param DeploymentConfig $deploymentConfig
+ * @param string|null $prefix
+ */
public function __construct(
ResourceConnection $resource,
DeploymentConfig $deploymentConfig,
@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* @return bool
* @throws InputException
* @throws AlreadyExistsException
+ * @throws \Zend_Db_Statement_Exception
*/
public function lock(string $name, int $timeout = -1): bool
{
+ if (!$this->deploymentConfig->isDbAvailable()) {
+ return true;
+ };
$name = $this->addPrefix($name);

/**
@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
if ($this->currentLock) {
throw new AlreadyExistsException(
new Phrase(
- 'Current connection is already holding lock for $1, only single lock allowed',
+ 'Current connection is already holding lock for %1, only single lock allowed',
[$this->currentLock]
)
);
@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface

$result = (bool)$this->resource->getConnection()->query(
"SELECT GET_LOCK(?, ?);",
- [(string)$name, (int)$timeout]
+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout]
)->fetchColumn();

if ($result === true) {
@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* @param string $name lock name
* @return bool
* @throws InputException
+ * @throws \Zend_Db_Statement_Exception
*/
public function unlock(string $name): bool
{
+ if (!$this->deploymentConfig->isDbAvailable()) {
+ return true;
+ };
+
$name = $this->addPrefix($name);

$result = (bool)$this->resource->getConnection()->query(
@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* @param string $name lock name
* @return bool
* @throws InputException
+ * @throws \Zend_Db_Statement_Exception
*/
public function isLocked(string $name): bool
{
+ if (!$this->deploymentConfig->isDbAvailable()) {
+ return false;
+ };
+
$name = $this->addPrefix($name);

return (bool)$this->resource->getConnection()->query(
"SELECT IS_USED_LOCK(?);",
- [(string)$name]
+ [$name]
)->fetchColumn();
}

@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* Limited to 64 characters in MySQL.
*
* @param string $name
- * @return string $name
+ * @return string
* @throws InputException
*/
private function addPrefix(string $name): string
Original file line number Diff line number Diff line change
@@ -1,142 +1,3 @@
diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php
--- a/vendor/magento/framework/Lock/Backend/Database.php
+++ b/vendor/magento/framework/Lock/Backend/Database.php
@@ -3,8 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
declare(strict_types=1);
+
namespace Magento\Framework\Lock\Backend;

use Magento\Framework\App\DeploymentConfig;
@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Phrase;

+/**
+ * Implementation of the lock manager on the basis of MySQL.
+ */
class Database implements \Magento\Framework\Lock\LockManagerInterface
{
- /** @var ResourceConnection */
+ /**
+ * Max time for lock is 1 week
+ *
+ * MariaDB does not support negative timeout value to get infinite timeout,
+ * so we set 1 week for lock timeout
+ */
+ const MAX_LOCK_TIME = 604800;
+
+ /**
+ * @var ResourceConnection
+ */
private $resource;

- /** @var DeploymentConfig */
+ /**
+ * @var DeploymentConfig
+ */
private $deploymentConfig;

- /** @var string Lock prefix */
+ /**
+ * @var string Lock prefix
+ */
private $prefix;

- /** @var string|false Holds current lock name if set, otherwise false */
+ /**
+ * @var string|false Holds current lock name if set, otherwise false
+ */
private $currentLock = false;

+ /**
+ * @param ResourceConnection $resource
+ * @param DeploymentConfig $deploymentConfig
+ * @param string|null $prefix
+ */
public function __construct(
ResourceConnection $resource,
DeploymentConfig $deploymentConfig,
@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* @return bool
* @throws InputException
* @throws AlreadyExistsException
+ * @throws \Zend_Db_Statement_Exception
*/
public function lock(string $name, int $timeout = -1): bool
{
+ if (!$this->deploymentConfig->isDbAvailable()) {
+ return true;
+ };
$name = $this->addPrefix($name);

/**
@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
if ($this->currentLock) {
throw new AlreadyExistsException(
new Phrase(
- 'Current connection is already holding lock for $1, only single lock allowed',
+ 'Current connection is already holding lock for %1, only single lock allowed',
[$this->currentLock]
)
);
@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface

$result = (bool)$this->resource->getConnection()->query(
"SELECT GET_LOCK(?, ?);",
- [(string)$name, (int)$timeout]
+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout]
)->fetchColumn();

if ($result === true) {
@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* @param string $name lock name
* @return bool
* @throws InputException
+ * @throws \Zend_Db_Statement_Exception
*/
public function unlock(string $name): bool
{
+ if (!$this->deploymentConfig->isDbAvailable()) {
+ return true;
+ };
+
$name = $this->addPrefix($name);

$result = (bool)$this->resource->getConnection()->query(
@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* @param string $name lock name
* @return bool
* @throws InputException
+ * @throws \Zend_Db_Statement_Exception
*/
public function isLocked(string $name): bool
{
+ if (!$this->deploymentConfig->isDbAvailable()) {
+ return false;
+ };
+
$name = $this->addPrefix($name);

return (bool)$this->resource->getConnection()->query(
"SELECT IS_USED_LOCK(?);",
- [(string)$name]
+ [$name]
)->fetchColumn();
}

@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
* Limited to 64 characters in MySQL.
*
* @param string $name
- * @return string $name
+ * @return string
* @throws InputException
*/
private function addPrefix(string $name): string
diff -Nuar a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php
--- a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php
+++ b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php
Expand Down
Loading