Skip to content

Commit 1cc3787

Browse files
Catch AfterCommitException from AbstractResource.php
If a callback in commit throws an excecption, the calling plugin needs to be able to distinguish this from a unsuccessful commit, so that it doesn't attempt a rollback on an already commited transaction. (Which would cause an “Asymmetric transaction rollback" error)
1 parent 6970611 commit 1cc3787

File tree

16 files changed

+36
-0
lines changed

16 files changed

+36
-0
lines changed

app/code/Magento/Authorization/Model/ResourceModel/Rules.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule)
121121

122122
$connection->commit();
123123
$this->aclDataCache->clean();
124+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
125+
throw $e->getPrevious();
124126
} catch (\Magento\Framework\Exception\LocalizedException $e) {
125127
$connection->rollBack();
126128
throw $e;

app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
102102
$output->writeln("<info>Unused product attributes successfully cleaned up:</info>");
103103
$output->writeln("<comment> " . implode("\n ", $attributeTables) . "</comment>");
104104
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
105+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
106+
throw $e->getPrevious();
105107
} catch (\Exception $exception) {
106108
$this->attributeResource->rollBack();
107109

app/code/Magento/Catalog/Model/Category.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ public function move($parentId, $afterCategoryId)
429429

430430
// Set data for indexer
431431
$this->setAffectedCategoryIds([$this->getId(), $oldParentId, $parentId]);
432+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
433+
throw $e->getPrevious();
432434
} catch (\Exception $e) {
433435
$this->_getResource()->rollBack();
434436
throw $e;

app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function aroundSave(
4444
$result = $proceed($product, $saveOptions);
4545
$this->resourceModel->commit();
4646
return $result;
47+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
48+
throw $e->getPrevious();
4749
} catch (\Exception $e) {
4850
$this->resourceModel->rollBack();
4951
throw $e;
@@ -69,6 +71,8 @@ public function aroundDelete(
6971
$result = $proceed($product);
7072
$this->resourceModel->commit();
7173
return $result;
74+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
75+
throw $e->getPrevious();
7276
} catch (\Exception $e) {
7377
$this->resourceModel->rollBack();
7478
throw $e;
@@ -94,6 +98,8 @@ public function aroundDeleteById(
9498
$result = $proceed($productSku);
9599
$this->resourceModel->commit();
96100
return $result;
101+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
102+
throw $e->getPrevious();
97103
} catch (\Exception $e) {
98104
$this->resourceModel->rollBack();
99105
throw $e;

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function reindexAll()
7777
$this->_removeNotVisibleEntityFromIndex();
7878
$this->syncData();
7979
$this->commit();
80+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
81+
throw $e->getPrevious();
8082
} catch (\Exception $e) {
8183
$this->rollBack();
8284
throw $e;

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public function reindexAll()
167167
try {
168168
$this->reindex();
169169
$this->commit();
170+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
171+
throw $e->getPrevious();
170172
} catch (\Exception $e) {
171173
$this->rollBack();
172174
throw $e;

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public function reindexAll()
119119
try {
120120
$this->_prepareIndexTable();
121121
$this->commit();
122+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
123+
throw $e->getPrevious();
122124
} catch (\Exception $e) {
123125
$this->rollBack();
124126
throw $e;

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ private function addCommitCallback(ResourceCategory $resourceCategory, \Closure
4848
}
4949
});
5050
$resourceCategory->commit();
51+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
52+
throw $e->getPrevious();
5153
} catch (\Exception $e) {
5254
$resourceCategory->rollBack();
5355
throw $e;

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ private function addCommitCallback(ResourceProduct $productResource, \Closure $p
5353
$this->reindexRow($product->getEntityId());
5454
});
5555
$productResource->commit();
56+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
57+
throw $e->getPrevious();
5658
} catch (\Exception $e) {
5759
$productResource->rollBack();
5860
throw $e;

app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function aroundSave(
4444
$result = $proceed($customer, $passwordHash);
4545
$this->resourceModel->commit();
4646
return $result;
47+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
48+
throw $e->getPrevious();
4749
} catch (\Exception $e) {
4850
$this->resourceModel->rollBack();
4951
throw $e;

0 commit comments

Comments
 (0)