ACP2E-5077: Concurrent customerCart GraphQL queries or POST /V1/carts/mine REST requests create duplicate active carts

The ACP2E-5077 patch fixes the issue where concurrent customerCart GraphQL queries or POST /V1/carts/mine REST requests create duplicate active carts for accounts that do not already have an active cart. This patch is available when the Quality Patches Tool (QPT) 1.1.85 is installed. The patch ID is ACP2E-5077. Please note that this issue is scheduled to be fixed in Adobe Commerce 2.4.10.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.7-p10, 2.4.8-p5

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.7-p7 - 2.4.9
NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

Concurrent customerCart GraphQL queries or POST /V1/carts/mine REST requests create duplicate active carts for accounts that do not already have an active cart.

Steps to reproduce:

  1. Make sure that the account has no active cart:

    code language-sql
    UPDATE quote SET is_active = 0 WHERE customer_id = <customer_id> AND is_active = 1;
    
  2. Generate a token:

    code language-graphql
    mutation {
      generateCustomerToken(email: "<email>", password: "<password>") {
        token
      }
    }
    
  3. Send two customerCart GraphQL queries at the same time with the same token, for example:

    code language-bash
    for i in 1 2; do
      curl -s '<base-url>/graphql' -H 'Content-Type: application/json' -H 'Authorization: Bearer <token>' \
        --data '{"query":"{ customerCart { id email } }"}' &
    done; wait
    
  4. Check the active carts:

    code language-sql
    SELECT customer_id, COUNT(*) AS cnt, GROUP_CONCAT(entity_id ORDER BY entity_id) AS quote_ids
    FROM quote
    WHERE is_active = 1 AND customer_id = <customer_id>
    GROUP BY customer_id;
    
  5. Repeat steps one to four with two concurrent POST /V1/carts/mine REST requests that use the same token.

Expected results:

  1. Both requests return the same cart ID.
  2. The account has one active cart.

Actual results:

  1. The requests return different cart IDs.
  2. The account has two active carts.

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

recommendation-more-help
commerce-operations-help-tools