Skip to content

Commit 84bbcb4

Browse files
committed
ACP2E-2055: Duplicate orders with same Quote Id at same time with few time difference
1 parent c308d4c commit 84bbcb4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class QuoteManagement implements CartManagementInterface, ResetAfterRequestInter
5555
{
5656
private const LOCK_PREFIX = 'PLACE_ORDER_';
5757

58-
private const LOCK_TIMEOUT = 10;
59-
6058
/**
6159
* @var EventManager
6260
*/
@@ -615,13 +613,12 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
615613
);
616614

617615
$lockedName = self::LOCK_PREFIX . $quote->getId();
618-
if ($this->lockManager->isLocked($lockedName)) {
616+
if (!$this->lockManager->lock($lockedName, 0)) {
619617
throw new LocalizedException(__(
620618
'A server error stopped your order from being placed. Please try to place your order again.'
621619
));
622620
}
623621
try {
624-
$this->lockManager->lock($lockedName, self::LOCK_TIMEOUT);
625622
$order = $this->orderManagement->place($order);
626623
$quote->setIsActive(false);
627624
$this->eventManager->dispatch(
@@ -632,11 +629,11 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
632629
]
633630
);
634631
$this->quoteRepository->save($quote);
635-
$this->lockManager->unlock($lockedName);
636632
} catch (\Exception $e) {
637-
$this->lockManager->unlock($lockedName);
638633
$this->rollbackAddresses($quote, $order, $e);
639634
throw $e;
635+
} finally {
636+
$this->lockManager->unlock($lockedName);
640637
}
641638
return $order;
642639
}

0 commit comments

Comments
 (0)