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.

CommentFileSizeAuthor
#9 d7-system_update_7007-1475342-9_testonly.patch2.07 KBiamEAP
FAILED: [[SimpleTest]]: [MySQL] 39,287 pass(es), 2 fail(s), and 0 exception(s). View
#9 d7-system_update_7007-1475342-9.patch2.68 KBiamEAP
PASSED: [[SimpleTest]]: [MySQL] 39,873 pass(es). View
#4 core-system_update_7007-1475342-4.patch630 bytesiamEAP
PASSED: [[SimpleTest]]: [MySQL] 37,732 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

Kasper Souren’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
PASSED: [[SimpleTest]]: [MySQL] 37,732 pass(es). View

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.

Kasper Souren’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
PASSED: [[SimpleTest]]: [MySQL] 39,873 pass(es). View
2.07 KB
FAILED: [[SimpleTest]]: [MySQL] 39,287 pass(es), 2 fail(s), and 0 exception(s). View

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.

Kasper Souren’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
Joseph Zhao’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.