Problem/Motivation
When running drush convert-field-collection I am getting:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-2711-0-0-und' for key 'PRIMARY': INSERT INTO ...
I am not sure what is causing this yet.
Proposed resolution
I am looking into this now but figured I would post this here to get some more attention.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | multifield-drush-convert-pdo-exception-2642136-11.patch | 630 bytes | elijah lynn |
| #4 | Selection_628.png | 20.66 KB | elijah lynn |
Comments
Comment #2
elijah lynnPossibly related to #2327317: Integrity constraint violation when saving multifield with a file subfield but I don't think so because the errors are different. The field collection in question does have an image field.
Comment #3
elijah lynnI should note also that this is happening on two different field collections. One has an image and the other one doesn't. I don't think it is related but I will leave it linked I suppose, just in case.
Comment #4
elijah lynnSo it does appear that the primary key combo does exist already and when we do a drupal_write_record($table, $record) in drush_multifield_convert_field_collection_table() we are trying to insert a new record, not update an existing one.
Comment #5
elijah lynnComment #6
elijah lynnAfter reading through #2534348: multifield_get_next_id is brittle I feel like this is probably the solution.
Comment #7
elijah lynnSo it actually appears that it only happens when there are 2 or more batches. I have 4 field collections the two that succeed are under 100 field collections. The two that fail are ~1,500 and ~3,000 entries.
While in xdebug, the second set tries to drupal_write_record() the same set the second time, therefore making duplicates. Still investigating.
Comment #8
elijah lynnI removed
drush_backend_batch_process();from multifield.drush.inc (line 122) to let the normal batch process do its thing and it got rid of this error and the conversion was successful! I think the multiple processes were not aware of where the other processes were. Haven't had time to look into how to make this actually work but wanted to post this feedback.Comment #9
elijah lynnLol, I guess I was thinking that it would use normal batch_process() if it wasn't specified because I think the Form API does that for forms. I am back to figuring out why the multiple processes are calling the same duplicate nid.
Comment #10
elijah lynnAlrighty, here is what I came up with but I am not sure how this is possible because I would think this is affecting everyone who does a drush migration from Field Collections but maybe not that many people use that?
On line 148 of multifield.drush.inc it is using the 'offset' but I don't see where that is declared. I changed it to 'count', which makes more sense and returns different records as is expected:
$query->range($context['sandbox']['offset'], 100);
I'll post a patch soon but this appears to fix the issue.
$query->range($context['sandbox']['count'], 100);
Comment #11
elijah lynnComment #14
dave reidD'oh! Committed to 7.x-1.x, thanks Elijah!