Duplicate webform ids in webform table

Created on 28 February 2018, almost 7 years ago
Updated 22 March 2023, over 1 year ago

I manage a large number of sites that operate under the same profile and config. Today one of them ran into an issue with a webform. Submitting a webform lead to a fatal error. I was seeing this in the log:

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'attendance_form-2' for key 'PRIMARY': UPDATE {webform} SET next_serial=:db_update_placeholder_0 WHERE webform_id = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 2 [:db_condition_placeholder_0] => attendance_form ) in Drupal\Core\Database\Connection->handleQueryException() (line 683 of /path/to/drupal/core/lib/Drupal/Core/Database/Connection.php).

Looking at the contents of the webform table:

$ drush @site sqlq "select * from webform"
attendance_form 1
attendance_form 4
attendance_form_2   1

It somehow created a duplicate id for "attendance_form" and then went on to create another id for "attendance_form_2" which it seems that the submissions were causing more errors on with an id of 'attendance_form-2' based on the error message. I was able to resolve the error just by removing the duplicate records.

I manage over 200 sites operating under the same code base and configuration with this form. This is the first time we've run into this issue. We did recently upgrade to core 8.4.5 after the recent security update. What I don't have an explanation for is how it got into this state. I couldn't find anything similar in the current issue, so pardon if this is already a recognized problem that's already been dealt with. I'm just looking for any leads on what might have caused this. Yes, this is an older version of webform's 8.x beta branch, but I can't easily upgrade these sites in production outside of scheduled maintenance windows.

🐛 Bug report
Status

Closed: works as designed

Component

Code

Created by

🇺🇸United States bburg Washington D.C.

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.

  • 🇮🇳India vasanthanand

    I am also getting this issue on Drupal 9.5, This is the first time i was seeing the issue and not sure about the root cause , If some one aware kindly confirm

  • 🇺🇦Ukraine hamrant

    We had the same issue, 4 multi sites with similar webform but only one of them with this error

    Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'magnews-2' for key 'PRIMARY': UPDATE {webform} SET next_serial=:db_update_placeholder_0 WHERE webform_id = :db_condition_placeholder_0;

    DELETE FROM webform resolved issue, thanks @jrockowitz

Production build 0.71.5 2024