Order Storage Lock Release

Created on 18 August 2024, 29 days ago
Updated 2 September 2024, 15 days ago

Describe your bug or feature request.

OrderStorage->lockForUpdate() locks an order...for update!

The happy path occurs when the order is saved, and the lock is released. (The lock is also released if there is an exception during $order->save().)

There are two scenarios that are not accounted for, for releasing the lock.

  1. If an exception occurs after a call to OrderStorage->lockForUpdate(), but outside of an $order->save().
  2. If, after obtaining the lock, you determine that you cannot process the order. e.g. if the order needs to be in draft, and you checked for draft before requesting the lock, but after acquiring the lock, the order is no longer in draft.

We should add a releaseLock(int $order_id) method to OrderStorage.

Additionally, in PaymentCheckoutController, we should handle these two scenarios by checking

If a bug, provide steps to reproduce it from a clean install.

Since this is handling a race condition, this can be tricky to reproduce, but you can by:

  1. adding a breakpoint in PaymentCheckoutController.php at the line that calls OrderStorage->lockForUpdate()
  2. send two return requests to the return URL
  3. step each over the call, (one will get the lock, the other will be waiting to acquire)
  4. run the one that acquired the lock to completion
  5. step over on the other thread, and observe you are modifying a completed order
📌 Task
Status

Fixed

Version

2.0

Component

Order

Created by

🇺🇸United States TomTech

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024