system_update_7007() failed, it didn't finish. drush updatedb is constantly spawning the thing until it gives up, the most important part of the error: "Integrity constraint violation: 1062 Duplicate entry"

After inspection I found out a permission was occurring twice in the D6 permission table.
I'm not sure if this can happen a lot, but I don't recall doing anything weird on this D6 site.

It seems to help to add array_unique() as such:

    foreach (array_unique(explode(', ', $role->perm)) as $perm) {

If these double permissions are more common it could be nice to patch this - especially as more people will want to upgrade their D6 to D7.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

okokokok’s picture

Working on another site and encountering the exact same issue, with the exact same fix.

Here's the thing as a patch:

$ diff system.install.ORIG system.install
1884c1884
<     foreach (explode(', ', $role->perm) as $perm) {
---
>     foreach (array_unique(explode(', ', $role->perm)) as $perm) {
moskito’s picture

Status: Active » Needs review

Solution #1 solve it.

webchick’s picture

Status: Needs review » Active

We need a real patch so we can run it through testbot. There are instructions for creating those at http://drupal.org/node/707484. We should also add duplicate permission to the upgrade test DB dumps to show this error occurring, and to show that the proposed fix fixes it.

iamEAP’s picture

Status: Active » Needs review
FileSize
630 bytes

I actually just ran into this myself on a very large upgrade.

Attaching #1 as a patch to see what testbot thinks of it. I will simultaneously be re-running my upgrade to see if it fixes it for me.

iamEAP’s picture

Can confirm this worked on my personal upgrade as well. Never written a test before, but willing to give it a shot.

okokokok’s picture

Same thing happening on another upgrade from 6 to 7.
The patch fixed it again.

aspilicious’s picture

Version: 7.12 » 7.x-dev
Status: Needs review » Reviewed & tested by the community

I don't see anything wrong with this patch and if it helps people upgrading I'm not against it...

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Hm. IMO we should have some test coverage for this condition, unless there's a really compelling reason not to.

iamEAP’s picture

Status: Needs work » Needs review
FileSize
2.68 KB
2.07 KB

Patch with test only should fail. Patch with both test and the array_unique() fix should pass.

iamEAP’s picture

Issue tags: +D7 upgrade path

Tagging D7 upgrade path for wider visibility.

iamEAP’s picture

Edit: double-post.

okokokok’s picture

I keep on losing time on this. The very descriptive error I got doing drush updatedb was this:
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-opt-in or out of tracking' for key 'PRIMARY'"

Finally gave this patch a try and... it worked.

Please apply the patch.

rsbecker’s picture

I hate to revive this, but why has the patch not been included in 7.16?

iamEAP’s picture

Leo Pitt’s picture

Ran into this problem upgrading to 7.20 - and the patch in #1 seems to have solved it. Please apply

David_Rothstein’s picture

Priority: Normal » Major
iamEAP’s picture

Issue tags: -Needs tests
pandaski’s picture

Version: 7.x-dev » 7.20

Fixed my issue while upgrade from 6.x to 7.20

iamEAP’s picture

Version: 7.20 » 7.x-dev
Status: Needs review » Reviewed & tested by the community

I'm counting 4 thumbs up on this. Marking RTBC in hopes of getting it in to the next bugfix release.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +7.22 release notes

Yup, looks good. Committed to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/851bcf1

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