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:

<?php
   
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.

Files: 
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 ]

Comments

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

Here's the thing as a patch:

<?php
$ diff system.install.ORIG system.install
1884c1884
<     foreach (explode(', ', $role->perm) as $perm) {
---
>     foreach (
array_unique(explode(', ', $role->perm)) as $perm) {
?>

Status:Active» Needs review

Solution #1 solve it.

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.

Status:Active» Needs review
StatusFileSize
new630 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.

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

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

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...

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.

Status:Needs work» Needs review
StatusFileSize
new2.68 KB
PASSED: [[SimpleTest]]: [MySQL] 39,873 pass(es).
[ View ]
new2.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.

Issue tags:+D7 upgrade path

Tagging D7 upgrade path for wider visibility.

Edit: double-post.

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.

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

#9: d7-system_update_7007-1475342-9.patch queued for re-testing.

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

Priority:Normal» Major

Issue tags:-Needs tests

#9: d7-system_update_7007-1475342-9.patch queued for re-testing.

Version:7.x-dev» 7.20

Fixed my issue while upgrade from 6.x to 7.20

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.

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.