reactioncommerce/reaction

cancelOrderItem can't deal with concurrent requests properly

Open

#6493 opened on Jan 20, 2021

View on GitHub
 (16 comments) (1 reaction) (0 assignees)JavaScript (12,181 stars) (2,198 forks)batch import
buggood first issueneeds triage

Description

Issue Description

If cancelOrderItem is fired in parallel for multiple fulfillment groups of an order, only some of them might receive an update. You can see this in action on the current order admin, which fires them in parallel if you click "Cancel Order" (Might be reconsidered in general, network errors should not result in an order being partially cancelled.)

Steps to Reproduce

  1. Create an order with two fulfillment groups
  2. Click "Cancel order" in the admin
  3. Notice that only one of the fulfillment groups updated their status

Possible Solution

The reason for this is that the mutation will process the whole shipping array of an order in memory and write that to the db - Parallel updates to it will get lost. Options could either be to add some locking mechanism on this, or to just to rewrite this to make atomic operations instead of replacing the whole array.

Versions

latest

Contributor guide