Our customers are seeing the following error when they try to use the same webform more than once:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4359-15-2-0' for key 'PRIMARY': INSERT INTO {webform_submitted_data}
Basically they submit then fill out the form with different info and submit again. I think what's happening is that they are submitting then hitting the back button and then changing some info and submitting again. Ideally I think it would be nice if webform could handle this situation (not sure why it can't but I'd love to hear why). But ultimately I'd just settle for it failing more gracefully. Any help or light you can shed on this is most appreciated.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | webform_localization-serial_fix-9-9-7.43.patch | 563 bytes | sorinb |
Comments
Comment #1
danchadwick commented@bmartinP4 - Have you tried this with the 4.x branch? I'm pretty sure that I have used the back button and resubmitted a webform and gotten an additional submission.
Note that if you have custom code, the upgrade from 3.x to 4.x will require some adjustments, as is document on the module's page.
Comment #2
mfbI am seeing occasional duplicate entry errors when webform 4.x is under load (many webform submissions coming in per second). The cases I looked at so far involved two different anonymous users trying to use the same serial number.
Since this is a different error message I filed a new issue: #2304047: PDO Exception: Duplicate entry for key 'nid_serial'
Comment #3
liam morlandThis might be caused by a draft being saved between pages, resulting in the sid being issued, hence the duplicate.
Comment #4
danchadwick commented#2 is a different issue. Update to 7.x-4.x-dev or 7.x-4.0-rc5 (or later, when released). An issue with db_transaction has been fixed.
Comment #5
caspervoogt commentedRe: #2 and updating to 7.x-4.x-dev.. I was experiencing the same issue and updated to 7.x-4.x-dev after trying 7.x-4.0, but in both cases the integrity constraint violation persists,. and my form is only getting one submissions every few minutes.
I solved it by truncating my webform_submissions and webform_submitted_data tables (after backing them up first).
Comment #6
markjlee commentedI also have this issue with the same situation as @caspervoogt's case. I also had db_truncate, but it's just a workaround.
Comment #7
sorinb commentedWell, in my case the issue was actually in webform_localization module.
The following fix helped to get it corrected. Attaching the patch for webform_localization.
Comment #8
liam morland@sorinb If the problem is in webform_localization, please open an issue in that queue and post a link to the issue here.
Comment #9
sorinb commentedSure, here it goes: https://www.drupal.org/node/2685897
Thanks for notification.
S.
Comment #10
kumardevan commentedWe do have this similar issue, due to this many mysql locks has been created on the mysql server & peformance of the site is very low. More over we are not using localization module .
We cannot truncate the table as well, since we need those data for reporting & other purposes.
Anyother solution to prevent this ?
Comment #11
kumardevan commentedComment #12
svt commentedI am also facing this similar issue, due to this many mysql locks has been created on the mysql server & performance of the site is very low. DB size is also huge as the data generation on the site is high, we also do not have localization module .
Any other solution to prevent this ?
Comment #13
nicolaj.knudsen@gmail.com commentedI can confirm that this issue is still present in webform 4.12.
We have seen it twice with a day in between, both times in the same very large webform (hundreds of components on 8 pages).
I can't reproduce it, but the components that fail are both the leafs on a conditional structure (i.e. they are hidden per default until a certain choice is made on another question). We have 32 of these conditional questions on the same page.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '291-952-364-0' for key 'PRIMARY': INSERT INTO {webform_submitted_data} (nid, sid, cid, no, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 291 [:db_insert_placeholder_1] => 952 [:db_insert_placeholder_2] => 364 [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => ) in drupal_write_record() (line 7334 of /var/www/html/includes/common.inc).
Comment #14
liam morlandWhen you say you see it twice a day, how busy is this form?
Comment #15
nicolaj.knudsen@gmail.com commented@Liam
I should have worded that message more clearly: I have only seen the error twice in total, one on nov. 9 2016 and one the next day nov 10. 2016
Comment #16
liam morlandDoes anyone see this with any regularity or can they reproduce it? It will be very hard to solve if it just happens seemingly randomly.
Comment #17
nicolaj.knudsen@gmail.com commentedThis error is very erratic. For two months we've had no problems, but in the last two weeks I've seen it three times in total.
Two of them was triggered by the same user on the same form, but on two different components. The third was on a different form altogether. There have been no hard load on the server (that I can see) when it happens. There is not really a pattern to it, and I've never been able to reproduce it.
I know this doesn't help much, I'm a bit at a loss here.
Comment #18
liam morlandI wonder if different users are being given the same sid. Next time this happens, take note of the primary key which is triggering the error then see if there is another user's submission which has the same sid.
Comment #19
martinhansen commentedI'm seeing something that appears to be similar. Currently using:
drupal 7.63
webform 7.x-4.19
webform_block 7.x-1.2
webform_civicrm 7.x-4.24
webform_layout 7.x-2.3
webform_localization 7.x-4.14
Will try to investigate and report back. This might be the issue reported by sorinb in #9.
Comment #20
cbeireis commentedI was able to duplicate the issue and figure out what is happening. When this happens the webform_submissions table did not get an entry in a previous request, but when the information is added there is already information for that sid in the webform_submitted_data table.
This will generate the error. I have not figured out why the submissions table did not get populated on a previous request. What we are doing to work around the problem is to clear any orphaned data in the webform_submitted_data table before submitting the form.
Comment #21
liam morlandIf there is a crash part-way through inserting the data for a new submission, something like this could happen. Proper use of transactions would prevent it (as would foreign keys, but that is another story). Something to look at is whether submitting a new submission is completely inside a transaction.
Comment #22
liam morlandI have added more use of transactions in #3052549: Increase use of transactions.
Comment #23
liam morlandDrupal 7 is no longer supported. If this applies to a supported version, please re-open.