Integrity constraint violation: 1062 Duplicate entry during site updates

Created on 19 October 2023, about 1 year ago

Problem/Motivation

When running an updb hook that alters nodes and does a lot of node saves on a site with recent items enabled. Each save triggers a menu rebuild, which can cause:

> SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'admi
> n_toolbar_content.menu_links:content.news_article.entity.313' for key 'id':
> INSERT INTO "menu_tree" ("id", "menu_name") VALUES (:db_insert_placeholder
> _0, :db_insert_placeholder_1); Array
> (
> [:db_insert_placeholder_0] => admin_toolbar_content.menu_links:content.
> news_article.entity.313
> [:db_insert_placeholder_1] => admin
> )

Steps to reproduce

Run a updb hook doing a lot of node saves.

Proposed resolution

Only rebuild the menu if we are online (no maintenance mode).

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇧🇪Belgium kriboogh

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

Comments & Activities

Production build 0.71.5 2024