Skip to content

Asymmetric transaction rollback Exception overthrows SQL error, impedes debugging #6465

@kweij

Description

@kweij

Preconditions

  1. Add an attribute to Customer and use it in grid, e.g.:
$this->eavSetup->addAttribute(
    Customer::ENTITY,
    'some_value',
    [
        'label' => 'Some value',
        'type' => 'varchar',
        'input' => 'text',
        'position' => 105,
        'sort_order' => 105,
        'visible' => true,
        'required' => false,
        'system' => false,
        'is_used_in_grid' => true,
    ]
);
  1. Forget (hey, everybody's got to learn) to add the attribute to the indexer
    (http://magento.stackexchange.com/a/116462/14759)

Steps to reproduce

  1. Add/save a new Customer

Expected result

The SQL error of the missing field in the customer_grid_flat table. Or maybe an Exception that let's me know that I intend to use a certain attribute in a grid but I forgot to add XML-configuration (etc/indexer.xml) for the indexer. Or even better yet, why the double declaration? The information in etc/indexer.xml is redundant so configuration for the indexer could be extracted from the attribute configuration directly.

The main problem is that the rollback failed, so a Customer was added to the DB but an Exception was still thrown which replaced the actual SQL error, impeding debugging.

Actual result

The method Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper::aroundSave throws an Exception with a clear SQL error, however $this->resourceModel->rollBack() throws an Exception with the message "Asymmetric transaction rollback". I couldn't find out why.

A Customer does get inserted into the database, but the frontend receive a "We can't save the customer." Exception. The logging isn't on any help (found the problem using xdebug and aspirine):

main.CRITICAL: Exception message: Asymmetric transaction rollback.
Trace: #0 /path/to/website/vendor/magento/framework/Model/ResourceModel/AbstractResource.php(99): Magento\Framework\DB\Adapter\Pdo\Mysql->rollBack()
#1 /path/to/website/var/generation/Magento/Customer/Model/ResourceModel/Customer/Interceptor.php(661): Magento\Framework\Model\ResourceModel\AbstractResource->rollBack()
#2 /path/to/website/vendor/magento/module-customer/Model/Plugin/CustomerRepository/TransactionWrapper.php(48): Magento\Customer\Model\ResourceModel\Customer\Interceptor->rollBack()
#3 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper->aroundSave(Object(Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor), Object(Closure), Object(Magento\Customer\Model\Data\Customer), '43cada06c777d87...')
#4 /path/to/website/var/generation/Magento/Customer/Model/ResourceModel/CustomerRepository/Interceptor.php(26): Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor->___callPlugins('save', Array, Array)
#5 /path/to/website/vendor/magento/module-customer/Model/AccountManagement.php(710): Magento\Customer\Model\ResourceModel\CustomerRepository\Interceptor->save(Object(Magento\Customer\Model\Data\Customer), '43cada06c777d87...')
#6 /path/to/website/var/generation/Magento/Customer/Model/AccountManagement/Interceptor.php(141): Magento\Customer\Model\AccountManagement->createAccountWithPasswordHash(Object(Magento\Customer\Model\Data\Customer), '43cada06c777d87...', NULL)
#7 /path/to/website/vendor/magento/module-customer/Model/AccountManagement.php(662): Magento\Customer\Model\AccountManagement\Interceptor->createAccountWithPasswordHash(Object(Magento\Customer\Model\Data\Customer), '43cada06c777d87...', NULL)
#8 /path/to/website/var/generation/Magento/Customer/Model/AccountManagement/Interceptor.php(128): Magento\Customer\Model\AccountManagement->createAccount(Object(Magento\Customer\Model\Data\Customer), '123QWEasd', NULL)
#9 /path/to/website/vendor/magento/module-customer/Controller/Account/CreatePost.php(277): Magento\Customer\Model\AccountManagement\Interceptor->createAccount(Object(Magento\Customer\Model\Data\Customer), '123QWEasd', NULL)
#10 /path/to/website/var/generation/Magento/Customer/Controller/Account/CreatePost/Interceptor.php(24): Magento\Customer\Controller\Account\CreatePost->execute()
#11 /path/to/website/vendor/magento/framework/App/Action/Action.php(102): Magento\Customer\Controller\Account\CreatePost\Interceptor->execute()
#12 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#13 /path/to/website/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callParent('dispatch', Array)
#14 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Account\CreatePost\Interceptor), Array, 'storeCheck')
#15 /path/to/website/vendor/magento/module-customer/Controller/Plugin/Account.php(60): Magento\Customer\Controller\Account\CreatePost\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Customer\Controller\Plugin\Account->aroundDispatch(Object(Magento\Customer\Controller\Account\CreatePost\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 /path/to/website/var/generation/Magento/Customer/Controller/Account/CreatePost/Interceptor.php(39): Magento\Customer\Controller\Account\CreatePost\Interceptor->___callPlugins('dispatch', Array, Array)
#18 /path/to/website/vendor/magento/framework/App/FrontController.php(55): Magento\Customer\Controller\Account\CreatePost\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#19 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /path/to/website/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#21 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'storeCheck')
#22 /path/to/website/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#23 /path/to/website/vendor/magento/framework/Interception/Interceptor.php(142): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#24 /path/to/website/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#25 /path/to/website/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#26 /path/to/website/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#27 /path/to/website/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#28 {main} [] []

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions