Open damonadigital opened 2 months ago
This looks like it was the Craft garbage collection gc
command and not the update search indexes command?
Yes you are right, I will amend the title.
In trying to understand the error it looks like it is related to a constraint on a stripe payments intent table.
I can reproduce the issue by running php craft gc
and I get the following:
purging inactive carts ... Exception 'yii\db\IntegrityException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`cicerone_dev`.`craft_stripe_paymentintents`, CONSTRAINT `craft_stripe_paymentintents_craft_commerce_orders_id_fk` FOREIGN KEY (`orderId`) REFERENCES `craft_commerce_orders` (`id`))
The SQL being executed was: DELETE FROM `craft_elements` WHERE `id` IN (SELECT `orders`.`id`
FROM `craft_commerce_orders` `orders`
WHERE (NOT (`isCompleted`=TRUE)) AND (`orders`.`dateUpdated` <= '2024-01-22 09:32:46'))'
in /srv/users/cicerone/apps/cicerone-dev/vendor/yiisoft/yii2/db/Schema.php:676
Error Info:
Array
(
[0] => 23000
[1] => 1451
[2] => Cannot delete or update a parent row: a foreign key constraint fails (`cicerone_dev`.`craft_stripe_paymentintents`, CONSTRAINT `craft_stripe_paymentintents_craft_commerce_orders_id_fk` FOREIGN KEY (`orderId`) REFERENCES `craft_commerce_orders` (`id`))
)
Caused by: Exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`cicerone_dev`.`craft_stripe_paymentintents`, CONSTRAINT `craft_stripe_paymentintents_craft_commerce_orders_id_fk` FOREIGN KEY (`orderId`) REFERENCES `craft_commerce_orders` (`id`))'
Description
We've experienced an SQL Integrity constraint violation error a few times last week during crafts garbage collection task. Here's the full output:
Steps to reproduce
I've not managed to reproduce it manually and we haven't had the problem over the last few days. I thought it would be worth reporting incase you have any insight into the issue or if anyone else has had a similar problem.
Additional info
Craft CMS version: Craft Pro 4.8.3 Craft Commerce version: 4.5.2 Stripe for Craft Commerce version: 3.1.1 PHP version: 8.0.30
Thanks