-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Fixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseimprovementup for grabs
Description
Preconditions
- All current Magento 2 versions (2.0, 2.1.1)
Steps to reproduce
-
Let a commit callback throw an exception
Example:
- create a new search engine
<type name="Magento\Search\Model\AdapterFactory"> <arguments> <argument name="adapters" xsi:type="array"> <item name="dummy" xsi:type="string">Magento\Framework\Search\Adapter\Mysql\Adapter</item> </argument> </arguments> </type>- Do not register a corresponding indexer handler for
Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory - The commit callback from the fulltext indexer plugin will cause an exception "There is no such indexer handler: dummy"
-
Trigger this commit (for example, save a product)
Expected result
- Exception from the commit callback is thrown and can be catched later (for ex. by PHPUnit)
Actual result
rollback()is called aftercommit()already has been called for the same transaction, resulting in an “Asymmetric transaction rollback error” exception when Magento tries to commit or rollback the last transaction on the stack.
Possible solution
-
create a new exception type for exceptions during commit callbacks,
AfterCommitException -
Replace
throw $ewiththrow new AfterCommitException(null, null, $e);inAbstractResource::commit() -
In plugins that register commit callbacks, handle these exceptions separately:
} catch (AfterCommitException $e) { throw $e->getPrevious(); } catch (\Exception $e) { $productResource->rollBack(); throw $e; }
Please let me know if this solution would be acceptable, before I create a PR
tormit, nshiff, vijaymagentone, cdiacon, vlfesko and 10 more
Metadata
Metadata
Assignees
Labels
Fixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseimprovementup for grabs