Skip to content

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

@PascalBrouwers

Description

@PascalBrouwers

Reopening #6465

Preconditions

  1. Magento 2.1.4

Steps to reproduce

  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
  2. Add/save a new Customer

Expected result

  1. 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.

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

  1. 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.

So the real problem is that transaction rollback is overtrowing the ACTUAL error, making debugging near impossible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions