Skip to content

Commit 84f6a38

Browse files
committed
MC-22212: 1213 Deadlock found when trying to get lock
1 parent 96d6f5b commit 84f6a38

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/**
1212
* Abstract resource model. Can be used as base for indexer resources
1313
*
14+
* phpcs:disable Magento2.Classes.AbstractApi
1415
* @api
1516
* @since 100.0.2
1617
*/
@@ -23,6 +24,11 @@ abstract class AbstractResource extends \Magento\Framework\Model\ResourceModel\D
2324
*/
2425
protected $tableStrategy;
2526

27+
/**
28+
* @var bool
29+
*/
30+
private $isIsolationLevelSet = false;
31+
2632
/**
2733
* Class constructor
2834
*
@@ -60,6 +66,20 @@ protected function _getIndexAdapter()
6066
return $this->getConnection();
6167
}
6268

69+
/**
70+
* @inheritDoc
71+
*/
72+
public function getConnection()
73+
{
74+
$connection = parent::getConnection();
75+
if (!$this->isIsolationLevelSet) {
76+
$connection->query('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;');
77+
$this->isIsolationLevelSet = true;
78+
}
79+
80+
return $connection;
81+
}
82+
6383
/**
6484
* Get index table name with additional suffix
6585
*
@@ -120,8 +140,7 @@ public function insertFromTable($sourceTable, $destTable, $readToIndex = true)
120140
}
121141

122142
/**
123-
* Insert data from select statement of read adapter to
124-
* destination table related with index adapter
143+
* Insert data from select statement of read adapter to destination table related with index adapter
125144
*
126145
* @param Select $select
127146
* @param string $destTable

0 commit comments

Comments
 (0)