Orphans in commerce_order_item table

Created on 24 July 2019, over 5 years ago
Updated 7 September 2024, 4 months ago

I have noticed that I have many orphans of commerce_order_items in my table which have not an entry in commerce_order__order_items table.

When I run the following SQL query:

SELECT
 c.order_id,
 c.purchased_entity,
 c.title,
 c.created,
 co.order_items_target_id
FROM
 commerce_order_item c
JOIN
 commerce_order_item ci ON ci.order_id = c.order_id AND ci.purchased_entity = c.purchased_entity AND c.uuid != ci.uuid
LEFT JOIN 
 commerce_order__order_items co ON c.order_item_id = co.order_items_target_id	
ORDER BY c.order_id DESC
LIMIT 0,20;

I can see as a result things like:

ORDER ID          ID    TITLE        CREATED        REF to commerce_order__order_items
11387563	1183 Product 1 1563791135	4731849
11387563	1183 Product 1 1563791135	NULL
11387563	1331 Product 2 1563791083	NULL
11387563	1331 Product 2 1563791083	4731846

Last column shouldn't be NULL and you can also see that created has the same timestamp.

In terms of calculating the correct total price everything is just fine. But these orphans are also visible on the receipt for example.
This behavior happens every 20 orders....

The problem is I am NOT able to reproduce this behavior on my local env or even on production. BUT I can see in the DB that this is happening.
Btw..Combine is active in the CartManager in addOrderItem method.

Any thoughts on this one?

💬 Support request
Status

Active

Version

2.0

Component

Order

Created by

🇩🇪Germany carstenG

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024