Integrity constraint violation on cron run.

Created on 9 July 2024, 8 months ago

Problem/Motivation

Cron job executions results in a SQL error.

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '51207' for key 'PRIMARY': INSERT INTO "commerce_abandoned_carts" ("order_id", "status", "timestamp") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => 51207
    [:db_insert_placeholder_1] => 1
    [:db_insert_placeholder_2] => 1720523315
)
 in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 45 of /app/web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php).

Steps to reproduce

Create an order with more than one line item and run cron once the required amount of time has passed.

Proposed resolution

Make the query distinct.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom rattusrattus

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

Comments & Activities

Production build 0.71.5 2024