-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Backport] Root exception not logged on QuoteManagement::submitQuote #22037
[Backport] Root exception not logged on QuoteManagement::submitQuote #22037
Conversation
Github Issue: #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.
- support masking of root cause in frontend - remove stack trace for consecutive exception to comply to default behaviour
Hi @larsroettig. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Hi @sivaschenko, thank you for the review. |
Hi @larsroettig, thank you for your contribution! |
Original Pull Request
#21697
Description
If an exceptions happens in
\Magento\Sales\Api\OrderManagementInterface::place
or ansales_model_service_quote_submit_success
observer, the catch block itself fires an event. As you can not know, what these observers do, it should be wrapped in a try catch block itself.With the Magento core this will currently happen, for example if saving the order throws an exception. This causes a rollback in
\Magento\Framework\Model\ResourceModel\Db\AbstractDb::save
. Thecatch
in the order management triggers via an observer the method\Magento\CatalogInventory\Model\ResourceModel\Stock::correctItemsQty
. In this method the stock modification is secured in a transaction - as the connection is already in rollback mode, the exception with the message Rolled back transaction has not been completed correctly. is thrown.The problem is, that only the second exception is logged in
exception.log
- the preceding exception is very hard to find.To handle this I wrapped the catch block itself in a try catch and merge the information in a new exception. This new exception is handled as before and finds its way to the
exception.log
.Fixed Issues
Manual testing scenarios
I do not know another (simple) way of reproducing this bug, than introducing an exception in placement of order. In a real life scenario this exception may happen because of some runtime conditions (invalid credit card data - depending on PSP). It has to be either a rollback triggered in the try block of
\Magento\Sales\Api\OrderManagementInterface::place
or an exception in asales_model_service_quote_submit_failure
observers.\Magento\Sales\Model\ResourceModel\Order::_beforeSave
:throw new \Exception('root of all evil');
tail -f <magento_root>/var/log/excption.log
Example
Log message without fix
Log message with fix
Contribution checklist (*)