I am getting the following errors when trying to register for a simple event. I am using Rules 7x 2-7 and get the following error (anonymous user can register, no login account required):

DOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'registration-5-0-0-und' for key 'PRIMARY': INSERT INTO {field_data_field_name} (entity_type, entity_id, revision_id, bundle, delta, language, field_name_value, field_name_format) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => registration [:db_insert_placeholder_1] => 5 [:db_insert_placeholder_2] => 5 [:db_insert_placeholder_3] => name_phone_email [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => test [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 451 of C:\Inetpub\wwwroot\oaz\modules\field\modules\field_sql_storage\field_sql_storage.module).

I am wondering if the following issues are relevant to this error? I do have rules that apply to user and role.

https://www.drupal.org/node/1433288#comment-8312299
https://www.drupal.org/node/1771666#comment-8389531

Comments

lias’s picture

Update.

Applied the following patch to user.module but still experiencing the same error message and can't register for event.

https://www.drupal.org/files/issues/drupal-fix-user-insert-roles-1433288...

Also tried with the latest 7x1-dev version but made no difference.

lias’s picture

Update2

I have now disabled the rules that apply to the user entity and the registration works. But I need to have the rules available as they automate role assignment and redirect the user to specific pages.

berliner’s picture

I'm running into the same error without the rules module. Also running Entity Registration 1.3.

berliner’s picture

Seems, this has been due to data inconsistencies in my dev setup. I tried to trace the problem down, but after trying a few times it has been gone.

diggersworld’s picture

Hi guys, I'm having the same issue. The problem only occurs however for an anonymous user, if I do it whilst logged into the site it works fine. My hunch is I've probably missed something when allowing anonymous users to register for an event. Any ideas?

diggersworld’s picture

Similar outcome as berliner. I logged in as an admin and registered. This must have triggered something, because now anonymous users can register too.

ram4nd’s picture

I have the same issue, I haven't tracked it yet.

Manually truncating tables where the error happens, fixed the problem for me. I suspect that the problem came when I rolled back migration. The registration entity is probably just not built well enough.

sclsweb’s picture

I have also observed this error without Rules. It seems to have stopped happening after adding a new registration as an admin too (for now?).

Some other specs in case they matter for troubleshooting:
Drupal 7.36
Entity Registration 1.3
Entity API 1.6

sclsweb’s picture

Update: I believe this error was occurring because registrations were being saved with IDs that overwrote deleted registration info. There is still data for the deleted id ranges in separate tables for the fields we added to the registration forms (registrant name, phone number, etc.). Apparently data in those tables wasn't deleted when the registration they were related to was deleted.

I can't reproduce the errors anymore, and new registrations seem to be ID numbered normally regardless of deletions. Recently deleted registrations do not have undeleted data in the name/phone/etc field tables, so it seems fixed now.

I'm not sure it's stopped as a result of anything we did -- it might simply be because the new registration ID numbers finally exceed the overwritten ones now. Bleh!

jmickela’s picture

I'm getting this error and am having a hell of a time trying to debug it. sclsweb is right, the problem is coming up because ID numbers from deleted registrations are being reused, and the ghost data of registrations past is causing errors when the new data gets inserted.

The real question here is: Why do registrations sometimes not fully delete and why do their IDs get reused when that happens?

Looking at my database I can see that every time I delete a registration all the data is deleted and when I create a new registration it does not recycle the ID from the last deleted one.

I think part of the problem is that (I've read that) InnoDB doesn't store auto-increment data and will decide which value to use when the database server is started. Some cloud hosting setups will shut down servers that aren't in use, and spin them up on demand. This could lead to re-using of old IDs. It doesn't explain why the data in other tables isn't getting deleted, but it's all I have so far.

jmickela’s picture

Just tested this locally and it is the case that with a MySQL database using InnoDB if you restart MySQL the next ID you get will be the current highest value in the database + 1.

I'm not too sure there's anything that can be done about that since it's part of how the DB server works. So the only fix is to figure out why field data is sometimes not removed.

jami’s picture

gcb’s picture

Assigned: Unassigned » komejo
amytswan’s picture

Status: Active » Fixed

Issue of lingering field values no longer occurs using Entity API 7x-1.6 and Registration 7.x-14, closing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mrupsidown’s picture

Status: Closed (fixed) » Active

I am reopening this issue. I have the exact same problem with Registration 7.x-1.6 and Entity API 7x-1.6.

gcb’s picture

Assigned: komejo » Unassigned

@mrupsidown as you can see from the long list of comments, there are a variety of circumstances and some lack of clarity around how to reproduce this issue. In order to troubleshoot, we're going to need more info than the versions of Registration and Entity API. Are you using Rules? Are you using Rules triggers that effect users? Are you on a system with InnoDB? Have you been deleting registrations? When you reach a certain threshhold of new registrations, does the problem go away? How are you registering users: anonymous or logged-in? Have you used migrate? Please read through the entire comment thread and note any similarities or dis-similarities between prior users: as @amyvs noted, we closed this because we were unable to reproduce the problem with latest entity API, not because we submitted a solution.

sclsweb’s picture

This issue has just recurred on a client site with the following specs:

Entity Registration 7.x-1.6
Entity API 7.x-1.6

Are you using Rules? No

Are you using Rules triggers that effect users? No

Are you on a system with InnoDB? No -- MySQL

Have you been deleting registrations? Yes -- and/or deleting the events they are associated with.

When you reach a certain threshhold of new registrations, does the problem go away? Yes

How are you registering users: anonymous or logged-in? Anonymous

Have you used migrate? no

The site has 2 different registration types applied to events. Fields were recently added to one of the types. Possible connection to issue with SQL Integrity constraint violation - bundle not part of PRIMARY KEY?

This error message occurred for registration ID's 19-24. ID 25 was the first one that worked normally.
We now have registrations at ID's: 1, 2, 9, 17, 18, 25, 26.

Error message (sample for the one that occured at ID 19):
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'registration-19-0-0-und' for key 'PRIMARY': INSERT INTO {field_data_field_registrant_name} (entity_type, entity_id, revision_id, bundle, delta, language, field_registrant_name_value, field_registrant_name_format) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => registration [:db_insert_placeholder_1] => 19 [:db_insert_placeholder_2] => 19 [:db_insert_placeholder_3] => default [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => NAME REDACTED [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 514 of /SITEPATH-REDACTED/modules/field/modules/field_sql_storage/field_sql_storage.module).

bramvandenbulcke’s picture

I was having the exact same issue with a registration type with three extra fields attached to it. The registration link is put inside a node 'activity'.

For some reason, I had two ghost records in these three field tables (field_data_field_...): ID 1 and 4. I couldn't find ID 1 and 4 in the registration table. So, when creating a new registration, inside the three extra fields, the ID's are already taken, showing the 'integrity constraint violation' message.

I manually deleted the ghost records in the three field tables in the database and this solved the issue (for now).

If I delete a node with a registration attached to it, the registration records in the registration table are deleted but not the records in the field tables. I believe that's the underlying reason for this issue.

kevster’s picture

I just ran into this issue when using latest 7.x-2.0 dev & entity 7.x-1.8 I created one registration as admin then went to create one as anonymous and got this:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, mail, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 503 [:db_insert_placeholder_1] => k@xxxxx.co [:db_insert_placeholder_2] => 1488473539 ) in drupal_write_record() (line 7383 of /home/xxxx/public_html/xxxxx/includes/common.inc).

I havent been deleting any registrations previous to this but I have set up a rule to email admin when someone creates a new registration. I suspect this wasnt the cause though as the record did not get created which should happen before the rule fires.

Permissions set for anon and auth users to create bookings.

Additional fields added to booking form to collect more data

using rules: yes

triggers that affect users? no
-------------
EDIT
Seems to be an issue as its trying to create a new user - I also get the issue if Im logged in as admin but create a booking for another person and enter an email address on the form. tested this with the send admin email rule turned off.

pinueve’s picture

This happend also using: switch[case1, case2] statement inside rules UI action section, don't, use if, ifelse, ...this solved this error

john.oltman’s picture

Status: Active » Closed (outdated)