-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Duplicate orders with same Quote Id at same time with few time difference. #13952
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
Comments
@amitcedcoss, thank you for your report. |
I am working on this at #dmcdindia |
It happens when you click same time on the button.
Let me know which way you want to process. |
Just to further this, we have the issue and it appears to affect PayPal orders mainly- though this may be coincidence (using the baked in Braintree support this is). Is there anything we could use as a hot fix do you know? |
@magento-engcom-team any update regarding our issue? |
@magento-engcom-team I got the same issue too. The quote is same ID but it created 5 orders today. So I appreciate any updates for this. |
@magento-engcom-team Any update on this issue? The issue occur randomly and it created multiple order on my site mainly from using Cash on Delivery payment method. |
@tzy1992 I had a quick fixing solution. let me know if you want to view that. |
@buituanbg Please share the fix with me. Thank you |
@buituanbg Please could you share it on here for us all to see if possible. |
Hi @tzy1992 and @timbaker1991 use Magento\Framework\Event\Observer; class OrderPlacebefore implements ObserverInterface
}' app/code/TB/FixDuplicateOrder/registration.php \Magento\Framework\Component\ComponentRegistrar::register( |
@buituanbg Thanks for sharing the fix, for the event you are using |
yes, I used sales_order_place_before event. |
@buituanbg I am still getting duplicated order after apply the fix, both order created at the exact date and time. @magento-engcom-team Any update regarding this issue? |
@tzy1992 it seems you got other case. Let me know if you need support to debug. |
@tzy1992 @buituanbg @timbaker1991 @amitcedcoss |
General question: What would happen if there would be a (But in general I feel like this constraint should be set anyway?) |
@rauberdaniel I think the |
Any update on this issue? |
Any update on that issue .. it happens when create order from custom code .. not happen when place order regularly. |
This issue occurs randomly on one of our 2.3.0 project. Any update on this issue? |
Hello all. I have notice issue with duplicate orders with the same quote id. All of your cases can have different origin but it's generally related to bad architecture of exception handling and not using database transaction or locking mechanizm in \Magento\Quote\Model\QuoteManagement::submitQuote. Problem is in this code fragment. try {
$order = $this->orderManagement->place($order);
$quote->setIsActive(false);
$this->eventManager->dispatch(
'sales_model_service_quote_submit_success',
[
'order' => $order,
'quote' => $quote
]
);
$this->quoteRepository->save($quote);
} catch (\Exception $e) {
$this->rollbackAddresses($quote, $order, $e);
throw $e;
} author don't take in consideration that something can go wrong after line $order = $this->orderManagement->place($order); and this is huge mistake because we have event there and magento can have a ton of plugins on place after. In general I implement quick clean fix to handle most of the cases in our project with checks is order with quote_id has been placed in second line of the method using di for validateQuote. this->submitQuoteValidator->validateQuote($quote); I cannot share the code but it's pretty straightforward to implement. For people which are strugling with concurency I would suggect to add plugin around submitQuote to set lock on quote_id before and release lock after including my fix for checking is order with quote already exists. |
Hello All, I tried to fix the issue, so I setIsActive to false once customer placing the order. And in order to handle (in case there is an error while placing order), I set active to true again. Hope it's for good, I've test it at the same time almost 30 times. and it works well. |
This ticket had an internal Jira, and due to various reasons that Jira got processed and cancelled. Thanks for your all of your contributions and collaborations here! |
… time difference.](magento#13952)
Preconditions
Steps to reproduce
Observe order confirmation screen of both systems. (usually first time you will get an error about constraint violations. Try to repeat steps 1-6 again. Issue reproduces 100% from the second attempt)
Depending on your infrastructure, this bug may be challenging to reproduce. It requires all of the "Place order" button clicks to be processed concurrently by Magento. You will not see the bug if Magento is processing requests sequentially (as the second request will reference a cart ID that no longer exists).
Expected result
A single order has been placed.
Alternatively, if multiple requests are unavoidable: Only the first request to be processed.
Actual result
Two different orders have been placed with very few seconds as time difference with same quote Id.
The text was updated successfully, but these errors were encountered: