Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rolled back transaction has not been completed correctly" on Magento 2.1.15 #18752

Closed
adammprost opened this issue Oct 22, 2018 · 36 comments
Closed
Assignees
Labels
Component: Checkout Component: Payment Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response

Comments

@adammprost
Copy link

Description

When a guest order is placed in Magento\Checkout\Model\GuestPaymentInformationManagement::savePaymentInformationAndPlaceOrder(), the following is executed: $salesConnection->beginTransaction(); $checkoutConnection->beginTransaction(), which creates a nested set of DB transactions (e.g. Magento\Framework\DB\Adapter\Pdo\Mysql::_transactionLevel exceeds 1).

Magento is built to handle nested DB transactions, but the way GuestPaymentInformationManagement is architected, it's almost guaranteeing a critical exception. When $this->savePaymentInformation() is executed, the _transactionLevel is already at 2, which means that any rollbacks triggered inside savePaymentInformation() will lead to a Magento\Framework\DB\Adapter\AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE exception message thrown.

This is especially odd architecture when we compare it to synonymous class and method use for registered users: Magento\Checkout\Model\PaymentInformationManagement::savePaymentInformationAndPlaceOrder()

Preconditions (*)

  1. Magento 2.1.15
  2. PHP 7.0

Steps to reproduce (*)

  1. Configure any online payment method with sandbox credentials.
  2. Place a guest order with credit card details that trigger an error message from the payment processor.

Expected result (*)

  1. The customer is shown the "An error has occurred on the server.." message.
  2. The exception log is empty.

Actual result (*)

  1. The customer is shown the "An error has occurred on the server.." message.
  2. The exception log has a critical exception of "Rolled back transaction has not been completed correctly."
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Oct 22, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 22, 2018

Hi @adammprost. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@adammprost do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@kanduvisla
Copy link
Contributor

I'm running into this issue as well after updating from Magento 2.1.15 to 2.2.6. Here's a stack trace that triggers the error in my production server (tested it first on acceptance, but there this issue doesn't happen :-/):

#0 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-catalog-inventory/Model/ResourceModel/Stock.php(174): Magento\Framework\DB\Adapter\Pdo\Mysql->beginTransaction()
#1 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-catalog-inventory/Model/StockManagement.php(151): Magento\CatalogInventory\Model\ResourceModel\Stock->correctItemsQty(Array, 0, '+')
#2 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-catalog-inventory/Observer/RevertQuoteInventoryObserver.php(67): Magento\CatalogInventory\Model\StockManagement->revertProductsSale(Array, 0)
#3 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver->execute(Object(Magento\Framework\Event\Observer))
#4 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver), Object(Magento\Framework\Event\Observer))
#5 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#6 /home/Vendor-webshop/releases/release-production-20181023-085210/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('sales_model_ser...', Array)
#7 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-quote/Model/QuoteManagement.php(534): Magento\Framework\Event\Manager\Proxy->dispatch('sales_model_ser...', Array)
#8 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-quote/Model/QuoteManagement.php(406): Magento\Quote\Model\QuoteManagement->submitQuote(Object(Magento\Quote\Model\Quote\Interceptor), Array)
#9 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-quote/Model/QuoteManagement.php(364): Magento\Quote\Model\QuoteManagement->submit(Object(Magento\Quote\Model\Quote\Interceptor))
#10 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-quote/Model/GuestCart/GuestCartManagement.php(87): Magento\Quote\Model\QuoteManagement->placeOrder('17289', NULL)
#11 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php(106): Magento\Quote\Model\GuestCart\GuestCartManagement->placeOrder('5y5G97NRZinMKGJ...')
#12 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Model\GuestPaymentInformationManagement->savePaymentInformationAndPlaceOrder('5y5G97NRZinMKGJ...', 'giel.berkers@is...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))
#13 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Interception/Interceptor.php(138): Vendor\BpostShipping\Rewrite\Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callParent('savePaymentInfo...', Array)
#14 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Interception/Interceptor.php(153): Vendor\BpostShipping\Rewrite\Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}('5y5G97NRZinMKGJ...', 'giel.berkers@is...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))
#15 /home/Vendor-webshop/releases/release-production-20181023-085210/generated/code/Vendor/BpostShipping/Rewrite/Magento/Checkout/Model/GuestPaymentInformationManagement/Interceptor.php(39): Vendor\BpostShipping\Rewrite\Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callPlugins('savePaymentInfo...', Array, Array)
#16 [internal function]: Vendor\BpostShipping\Rewrite\Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder('5y5G97NRZinMKGJ...', 'giel.berkers@is...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))
#17 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)
#18 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/module-webapi/Controller/Rest.php(244): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))
#19 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)
#21 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#22 /home/Vendor-webshop/releases/release-production-20181023-085210/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
#23 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /home/Vendor-webshop/releases/release-production-20181023-085210/vendor/magento/framework/App/Bootstrap.php(257): Magento\Framework\App\Http->launch()
#25 /home/Vendor-webshop/releases/release-production-20181023-085210/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#26 {main}{"message":"Er is een fout opgetreden op de server. Probeer de bestelling opnieuw te plaatsen."}

@kanduvisla
Copy link
Contributor

@adammprost : did you found a (temporary) solution to this problem?

@kanduvisla
Copy link
Contributor

I found the issue in my case: I set the customer date of birth on the quote object, but the format was incorrect.

If anyone else bumps into this issue: your problem might be something else. This error (with a very generic "something went wrong" message and not a very clear stack trace) is caused if a transaction has been rolled back and is being re-opened later on.

The easiest way to debug this is by checking what process is triggering you rollback()-method. So if you add a very simple command at the beginning of \Magento\Framework\DB\Adapter\Pdo\Mysql::rollBack() you can debug this in your specific case:

echo (new \Exception())->getTraceAsString();

However, I do agree with @adammprost his comment that this setup can lead to some nasty situations that are difficult to debug.

@ghost ghost self-assigned this Nov 6, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Nov 6, 2018

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Component: Checkout Component: Payment Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Nov 6, 2018
@magento-engcom-team
Copy link
Contributor

@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-96154, MAGETWO-96155 were created

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Nov 6, 2018
@ghost ghost removed their assignment Nov 6, 2018
@atsareva
Copy link

atsareva commented Dec 6, 2018

Hi! Any progress for this issue? Client said that he got a lot of messages from customers regarding this issue. I think it's urgent because when customers get 'An error has occurred on the server..', they don't know what they should do.

@jkuczek15
Copy link

Has anyone found a temporary solution to this? Still having problems when placing an order.

@weverson83
Copy link

I find out how to reproduce it:
It happens when a roll back is called and you catch the exception.

class RollbackExceptionTest extends \PHPUnit\Framework\TestCase
{
    /**
     * @magentoDbIsolation enabled
     */
    public function testRollbackException()
    {
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

        $resource = $objectManager->get(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set::class);
        $attributeSet = $this->getAttrSetInstance($objectManager);

        //Save new entity
        $resource->save($attributeSet);

        //Saving the second time throws AlreadyExistsException
        try {
            $attributeSet = $this->getAttrSetInstance($objectManager);
            $resource->save($attributeSet);
        } catch (\Magento\Framework\Exception\AlreadyExistsException $exception) {
            $this->assertTrue(true, 'Exception is thrown');
        }
      
        //Saving the 3rd time, throws Rolled back transaction has not been completed correctly
        try {
            $attributeSet = $this->getAttrSetInstance($objectManager);
            $resource->save($attributeSet);
        } catch (\Magento\Framework\Exception\AlreadyExistsException $exception) {
            $this->assertTrue(true, 'Exception is thrown');
        }
    }

    private function getAttrSetInstance(\Magento\Framework\App\ObjectManager $objectManager)
    {
        $factory = $objectManager->get(\Magento\Eav\Model\Entity\Attribute\SetFactory::class);
        $attributeSet = $factory->create();

        $attributeSet->setEntityTypeId(4);
        $attributeSet->setName('attrSetTest');

        return $attributeSet;
    }
}

To solve it, check in your code where those kind of exceptions are happening and fix it.

@josenacasabogiii
Copy link

I also had this issue after migrating from Magento 1.9.3 to Magento 2.3. Not sure how to fix it. Is there an update or quick fix to this one? Thank you!!

david-fuehr added a commit to david-fuehr/magento2 that referenced this issue Mar 8, 2019
Github Issue: magento#18752

If an exceptions happens in orderManagement->place($order) or an
"sales_model_service_quote_submit_success" observer, the catch block
itself fires an event that currently fails for guest checkouts in
Magento\CatalogInventory\Model\ResourceModel\Stock->correctItemsQty().

This second exception hides the root exception and is logged to
the exception log with the message "Rolled back transaction has not
been completed correctly".

This is not bound for this observer, but may occur in every other
observer that is currently register or may be registered in the future.

Therefore the failure event is wrapped in a try-catch itself and throws
a combined exception that is logged in the exception.log.
@josenacasabogiii
Copy link

I don't understand this error

An exception occurred on 'sales_model_service_quote_submit_failure' event: Rolled back transaction has not been completed correctly.
#0 /home/porcel12/public_html/products-new/vendor/magento/framework/Model/ResourceModel/AbstractResource.php(65): Magento\Framework\DB\Adapter\Pdo\Mysql->beginTransaction()
#1 /home/porcel12/public_html/products-new/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(397): Magento\Framework\Model\ResourceModel\AbstractResource->beginTransaction()
#2 /home/porcel12/public_html/products-new/vendor/magento/framework/Model/AbstractModel.php(648): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save(Object(Magento\Indexer\Model\Indexer\State))
#3 /home/porcel12/public_html/products-new/vendor/magento/module-indexer/Model/Indexer.php(447): Magento\Framework\Model\AbstractModel->save()
#4 /home/porcel12/public_html/products-new/vendor/magento/module-indexer/Model/Indexer/DependencyDecorator.php(271): Magento\Indexer\Model\Indexer->reindexList(Array)
#5 /home/porcel12/public_html/products-new/vendor/magento/framework/Indexer/AbstractProcessor.php(69): Magento\Indexer\Model\Indexer\DependencyDecorator->reindexList(Array)
#6 /home/porcel12/public_html/products-new/vendor/magento/module-inventory-sales/Observer/CatalogInventory/RevertQuoteInventoryObserver.php(49): Magento\Framework\Indexer\AbstractProcessor->reindexList(Array)
#7 /home/porcel12/public_html/products-new/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Magento\InventorySales\Observer\CatalogInventory\RevertQuoteInventoryObserver->execute(Object(Magento\Framework\Event\Observer))
#8 /home/porcel12/public_html/products-new/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\InventorySales\Observer\CatalogInventory\RevertQuoteInventoryObserver), Object(Magento\Framework\Event\Observer))
#9 /home/porcel12/public_html/products-new/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#10 /home/porcel12/public_html/products-new/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('sales_model_ser...', Array)
#11 /home/porcel12/public_html/products-new/vendor/magento/module-quote/Model/QuoteManagement.php(536): Magento\Framework\Event\Manager\Proxy->dispatch('sales_model_ser...', Array)
#12 /home/porcel12/public_html/products-new/vendor/magento/module-quote/Model/QuoteManagement.php(406): Magento\Quote\Model\QuoteManagement->submitQuote(Object(Magento\Quote\Model\Quote\Interceptor), Array)
#13 /home/porcel12/public_html/products-new/vendor/magento/module-quote/Model/QuoteManagement.php(364): Magento\Quote\Model\QuoteManagement->submit(Object(Magento\Quote\Model\Quote\Interceptor))
#14 /home/porcel12/public_html/products-new/vendor/magento/module-quote/Model/GuestCart/GuestCartManagement.php(87): Magento\Quote\Model\QuoteManagement->placeOrder('51', NULL)
#15 /home/porcel12/public_html/products-new/vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php(107): Magento\Quote\Model\GuestCart\GuestCartManagement->placeOrder('msTSRa3wPxuSgN8...')
#16 /home/porcel12/public_html/products-new/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Model\GuestPaymentInformationManagement->savePaymentInformationAndPlaceOrder('msTSRa3wPxuSgN8...', 'jnacasabog3@gma...', Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address))
#17 /home/porcel12/public_html/products-new/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callParent('savePaymentInfo...', Array)
#18 /home/porcel12/public_html/products-new/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->Magento\Framework\Interception{closure}('msTSRa3wPxuSgN8...', 'jnacasabog3@gma...', Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address))
#19 /home/porcel12/public_html/products-new/generated/code/Magento/Checkout/Model/GuestPaymentInformationManagement/Interceptor.php(26): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callPlugins('savePaymentInfo...', Array, Array)
#20 [internal function]: Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder('msTSRa3wPxuSgN8...', 'jnacasabog3@gma...', Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address))
#21 /home/porcel12/public_html/products-new/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)
#22 /home/porcel12/public_html/products-new/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))
#23 /home/porcel12/public_html/products-new/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /home/porcel12/public_html/products-new/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)
#25 /home/porcel12/public_html/products-new/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#26 /home/porcel12/public_html/products-new/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
#27 /home/porcel12/public_html/products-new/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#28 /home/porcel12/public_html/products-new/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#29 /home/porcel12/public_html/products-new/index.php(46): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#30 {main}

@david-fuehr
Copy link
Contributor

Hi @josenacasabogiii,

you used the first commit on this issue. I just added a second commit and created the pull request - try to use these changes.

The error message a stack trace you provide just shows the consecutive exception, that happens in RevertQuoteInventoryObserver.php.

The exception.log should already contain the preceding exception message. Please provide this, if you need further assistance on identifying your problem.

@dazz397
Copy link

dazz397 commented Mar 15, 2019

I upgraded from 2.1.10 to 2.2.7 and this started happening. It would only happen when there was a payment decline. I am using the authorize.net payment gateway from paradox labs. I am not sure it's related but the exception being caught that causes this error is a message from that module. You can replicate it by making a payment using CC: 4444333322221111 CVV:111 EXP:0120.

Now for the fix.

In /vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php

Go to function savePaymentInformationAndPlaceOrder and comment out the following lines:

//$salesConnection = $this->connectionPull->getConnection('sales');
//$checkoutConnection = $this->connectionPull->getConnection('checkout');
//$salesConnection->beginTransaction();
//$checkoutConnection->beginTransaction();

//$salesConnection->commit();
//$checkoutConnection->commit();

//$salesConnection->rollBack();
//$checkoutConnection->rollBack();

I did a diff with the same file from 2.1.10 and it looks like the database transaction code did not exist in that file so it is something new that was added causing the problem. For now, I just commented it out and everything works.

@magento-engcom-team
Copy link
Contributor

Hi @adammprost. Thank you for your report.
The issue has been fixed in #21697 by @david-fuehr in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Mar 29, 2019
@ghost ghost added Issue: ready for confirmation and removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Oct 21, 2020
@johnorourke
Copy link
Contributor

I'm seeing this issue in 2.3.4 when a credit card payment fails, as @rhoerr mentioned above:

Model/GuestPaymentInformationManagement.php in module-checkout wraps the placeOrder call with transactions, but the non-guest version doesn't. Part of the issue is that module-quote/Model/QuoteManagement.php's rollbackAddresses will catch any exception and turn it into a \Exception - this doesn't inherit from \Magento\Framework\Exception\LocalizedException and so module-checkout/Model/GuestPaymentInformationManagement.php turns it into the generic "An error occurred on the server. Please try to place the order again.", hiding the actual message.

Nested transactions aren't supported in mysql AFAIK.

Here's my understanding of where it happens, from reading the 2.3.4 code:

  • \Magento\Checkout\Model\GuestPaymentInformationManagement begins 2 transactions on different connections
  • \Magento\Quote\Model\QuoteManagement::placeOrder is called
  • \Magento\Quote\Model\QuoteManagement::submit is called
  • \Magento\Quote\Model\QuoteManagement::submitQuote is called
  • the sales_model_service_quote_submit_before event is dispatched... so far so good
  • \Magento\Sales\Api\OrderManagementInterface::place is called - say the payment method's capture method is called, and it throws a PaymentException here because the card details are wrong
  • \Magento\Quote\Model\QuoteManagement::submitQuote catches it, and calls rollbackAddresses (from Root exception not logged on QuoteManagement::submitQuote #21697)
  • \Magento\Quote\Model\QuoteManagement::rollbackAddresses deletes each address...
  • \Magento\Customer\Model\ResourceModel\Address::delete calls parent::delete
  • \Magento\Eav\Model\Entity\VersionControl\AbstractEntity::delete is inherited from...
  • \Magento\Eav\Model\Entity\AbstractEntity::delete which calls $this->transactionManager->start($this->getConnection())
  • \Magento\Eav\Model\Entity\AbstractEntity::getConnection calls getConnection on the \Magento\Framework\App\ResourceConnection it got from the object construction Context

So we have two issues:

  • \Magento\Eav\Model\Entity\AbstractEntity isn't using the Transaction wrapper Magento now provides - but that wouldn't solve it
  • having a DB transaction wrapped around a huge deep set of code like order placement will easily cause bugs like this - we should be able to trust the lower-level code (eg. stock changes) to handle errors with transactions, and throw a clean exception with no pending transactions

Checked latest code, and it's fixed in 2.4.1 - see "MC-29426: Orders in Payment System but not in Magento" ( 43e41fa ) which fixed #25862

@stale
Copy link

stale bot commented Mar 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

@stale stale bot added the stale issue label Mar 8, 2021
@huykon
Copy link

huykon commented Mar 16, 2021

I am facing with this issue when I use custom payment. I don't know how to resolve this, can anyone know to help me?

@stale stale bot removed the stale issue label Mar 16, 2021
@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

@stale stale bot added the stale issue label Jun 2, 2021
@engcom-Hotel engcom-Hotel self-assigned this Jun 15, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jun 15, 2021

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@stale stale bot removed the stale issue label Jun 15, 2021
@engcom-Hotel
Copy link
Contributor

Hi @adammprost

We have tried to reproduce this issue in Magento 2.4-develop, but it seems that this issue has already been resolved. Please try to reproduce this issue in 2.4-develop branch. Please reply on this ticket if you are able to reproduce this issue in this branch.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response labels Jun 17, 2021
@m2-community-project m2-community-project bot removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: ready for confirmation labels Jun 17, 2021
@engcom-Hotel engcom-Hotel added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Jun 17, 2021
@engcom-Hotel
Copy link
Contributor

Hi @adammprost,

It seems that your issue has been resolved. We are unable to get your response since 14 days, hence we are closing this issue for now.

If you still facing the issue, you can reopen the ticket or create a new ticket.

Thanks

@heqixi
Copy link

heqixi commented Jul 18, 2021

I encounter this issue on magento2.4.2, my reproduce steps are:

  1. create a customer account in my landing page;
  2. log in admin page, create a user (not a customer) account with the same email address which is used in step 1, and then save the user, the following excepion message was shown

i do not know how to fix, help me please !


1 exception(s):
Exception #0 (Exception): Rolled back transaction has not been completed correctly.

Exception #0 (Exception): Rolled back transaction has not been completed correctly.

#1 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#2 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#3 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:32]
#4 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->commit() called at [vendor/magento/framework/Model/ResourceModel/AbstractResource.php:93]
#5 Magento\Framework\Model\ResourceModel\AbstractResource->commit() called at [vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:426]
#6 Magento\Framework\Model\ResourceModel\Db\AbstractDb->save() called at [vendor/magento/framework/Model/AbstractModel.php:655]
#7 Magento\Framework\Model\AbstractModel->save() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#8 Magento\User\Model\User\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#9 Magento\User\Model\User\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#10 Magento\User\Model\User\Interceptor->___callPlugins() called at [generated/code/Magento/User/Model/User/Interceptor.php:581]
#11 Magento\User\Model\User\Interceptor->save() called at [vendor/magento/module-user/Controller/Adminhtml/User/Save.php:96]
#12 Magento\User\Controller\Adminhtml\User\Save->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#13 Magento\User\Controller\Adminhtml\User\Save\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#14 Magento\User\Controller\Adminhtml\User\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51]
#15 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#16 Magento\User\Controller\Adminhtml\User\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#17 Magento\User\Controller\Adminhtml\User\Save\Interceptor->___callPlugins() called at [generated/code/Magento/User/Controller/Adminhtml/User/Save/Interceptor.php:23]
#18 Magento\User\Controller\Adminhtml\User\Save\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#19 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:151]
#20 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#21 Magento\User\Controller\Adminhtml\User\Save\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#22 Magento\User\Controller\Adminhtml\User\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#23 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#24 Magento\User\Controller\Adminhtml\User\Save\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#25 Magento\User\Controller\Adminhtml\User\Save\Interceptor->___callPlugins() called at [generated/code/Magento/User/Controller/Adminhtml/User/Save/Interceptor.php:32]
#26 Magento\User\Controller\Adminhtml\User\Save\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:186]
#27 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:118]
#28 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#29 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#30 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#31 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23]
#32 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#33 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23]
#34 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#35 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:29]

@savandholu
Copy link

I'm facing errors when editing the products.
Can please help me out.
image

@savandholu
Copy link

I also had this issue after migrating from Magento 1.9.3 to Magento 2.3. Not sure how to fix it. Is there an update or quick fix to this one? Thank you!!

How will fix that issue? Can you please explain? @josenacasabogiii

@josenacasabogiii
Copy link

Hi @savan13

I fixed it by checking the sales order table with some duplicate entries on some increment order id or something like that. You have to check your Magento error logs to point out the specific error because this error is triggered in many different ways when it comes to magento migration. It was luck fixing it on my because I just read some similar issues in in stack Magento exchange and it was long time ago and I can't remember what I specifically did. I'm not really a good Magento developer because I only worked on this platform a few times.

Just let me know what you found on the errors maybe I can help a bit. Good luck!

@savandholu
Copy link

savandholu commented Jan 20, 2022

Hi @savan13

I fixed it by checking the sales order table with some duplicate entries on some increment order id or something like that. You have to check your Magento error logs to point out the specific error because this error is triggered in many different ways when it comes to Magento migration. It was luck fixing it on me because I just read some similar issues in stack Magento exchange and it was a long time ago and I can't remember what I specifically did. I'm not really a good Magento developer because I only worked on this platform a few times.

Just let me know what you found on the errors maybe I can help a bit. Good luck!

@josenacasabogiii

In error log shows this error: [2022-01-20 09:43:03] main.CRITICAL: Rolled back transaction has not been completed correctly. {"exception":"[object] (Exception(code: 0): Rolled back transaction has not been completed correctly. at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:310)"} []

Can please look into this?

@savandholu
Copy link

@josenacasabogiii Hope you are doing well !!

I have found that solution.
The solution is some 3rd part module database table not defined properly AUTO INCREMENT & PRIMARY KEY.
I have checked to disable one-by-one module & check them & got the error.
Now it's working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Checkout Component: Payment Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response
Projects
None yet
Development

No branches or pull requests