It's on drupal 7.25, and this is what happens when I try to update.

The following updates returned messages
metatag module
Update #7018

Fixed the revision_id values for 71 {metatag} records.
Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-929-5058-en' for key 'PRIMARY': UPDATE {metatag} SET revision_id=:db_update_placeholder_0 WHERE (entity_type = :db_condition_placeholder_0) AND (entity_id = :db_condition_placeholder_1) AND (revision_id = :db_condition_placeholder_2) AND (language = :db_condition_placeholder_3) ; Array ( [:db_update_placeholder_0] => 5058 [:db_condition_placeholder_0] => node [:db_condition_placeholder_1] => 929 [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => en ) in metatag_update_7018() (line 1126 of /srv/www/htdocs/drupal/sites/all/modules/metatag/metatag.install).

Comments

damienmckenna’s picture

Priority: Normal » Major
Parent issue: » #2117171: Plan for 7.x-1.0-beta8 on 2013-01-15

What version did you have prior to updating?

(bumping to Major as I want to release the new beta today, without any update bugs)

smudos’s picture

7.24

damienmckenna’s picture

Sorry, what version of *Metatag* did you have before you upgraded to the latest -dev release?

smudos’s picture

And, yeah, it was latest dev version of the module.

damienmckenna’s picture

Do you remember when you downloaded that version? The dev versions are rebuilt every 12 hours (or so), so it's hard to gauge anything based on this.

Was 7018 the only update that was listed when you ran the database updates?

smudos’s picture

well, I am getting thiss error for some time now. Let's say for about a week or two.

Here's what should be updated:

metatag module

7018 - Update the revision ID for each record. This may take some time.
7019 - Clear the entity_cache bins.
7020 - Clear the Metatag cache.
7021 - Clear the existing Metatag cache so all unwanted 403404 paths can be purged.
7022 - A minor bit of tidy-up after update 7015.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new2.06 KB

This should do it. The update wasn't verifying that there wasn't already a record for the nid/vid/langcode combination before creating the record. This should do it.

damienmckenna’s picture

Status: Needs review » Fixed

Committed.

troybthompson’s picture

I'm having the same issue and I'm using the dev version with the above patch. I was using the previous beta version before upgrading, tried beta 8 and got the error and now dev.

smudos’s picture

Nope. I still get the same error.

Update #7018

    Fixed the revision_id values for 71 {metatag} records.
    Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-929-5058-en' for key 'PRIMARY': UPDATE {metatag} SET revision_id=:db_update_placeholder_0 WHERE (entity_type = :db_condition_placeholder_0) AND (entity_id = :db_condition_placeholder_1) AND (revision_id = :db_condition_placeholder_2) AND (language = :db_condition_placeholder_3) ; Array ( [:db_update_placeholder_0] => 5058 [:db_condition_placeholder_0] => node [:db_condition_placeholder_1] => 929 [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => en ) in metatag_update_7018() (line 1126 of /srv/www/virtual/info.kontra-punkt/htdocs/kontradrupal/sites/all/modules/metatag/metatag.install).

This is what I get when I try to run update via drush, maybe that can help:

 Metatag  7018  Update the revision ID for each record. This may take some    
                time.                                                         
 Metatag  7019  Clear the entity_cache bins.                                  
 Metatag  7020  Clear the Metatag cache.                                      
 Metatag  7021  Clear the existing Metatag cache so all unwanted 403404 paths 
                can be  purged.                                               
 Metatag  7022  A minor bit of tidy-up after update 7015.
Do you wish to run all pending updates? (y/n): y

Performed update: metatag_update_7018                                [ok]
Update 7018: 151 records to update.                                  [status]
Update 7018: 1 records were updated.                                 [status]

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry[error]
'node-929-5058-en' for key 'PRIMARY'
Performed update: metatag_update_7018                                [ok]
grahamshepherd’s picture

One of my sites updated from beta 7 to beta 8 OK. On another site I got this message:

"The update process was aborted prematurely while running update #7018 in metatag.module. All errors have been logged. You may need to check the watchdog database table manually."

In the report log the message was Info: "Update 7018: 31 records to update."

I tried the Update process again and it appeared that 3 updates had proceeded but 5 remained. Again it aborted with the same message on the update page as above but no message in the reports log.

damienmckenna’s picture

Status: Fixed » Needs work

Ah… Hrm. I think I might know what the problem is. Would you mind checking your {metatag} table and see if there are multiple records for the node that's causing the error?

troybthompson’s picture

Yes, I have 12 rows for the node I got the error on, all different revision_id's.

damienmckenna’s picture

@troybthompson: Do you have a record with a revision_id "0"?

troybthompson’s picture

Yes.

node 529 und 0
node 529 und 5524
node 529 und 5525
node 529 und 5527
node 529 und 5528
node 529 und 5533
node 529 und 5534
node 529 und 5544
node 529 und 5545
node 529 und 5562
node 529 und 5563
node 529 und 5565

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new3.45 KB

This should, hopefully, resolve the problem.

The problem boils down to the fact that sites which were running the dev releases of Metatag for the past few months may have ended up with {metatag} records with a revision_id 0 and other records for the correct revision_id values. The update script was not written to handle that scenario so it borked. What this update does is first verifies that the new record doesn't exist, and if it does it deletes the older revision_id=0 one, the idea being that the record with a proper revision_id would have been newer.

Please test this on a copy of your site, just in case.

smudos’s picture

that's it. well done!

damienmckenna’s picture

Component: Miscellaneous » Code
Status: Needs review » Fixed

Ok, I've committed this but I've added an extended note for update 7018:

Update the revision ID for each record. This may take some time. Should any nodes be discovered with a meta tag record for both revision_id 0 and the correct revision_id, the "0" value will be deleted; if this is not the desired result the {metatag} table must be manually pruned to have the correct records prior to letting this update run.

I'll also create a change record to note this problem.

troybthompson’s picture

Perfect beta9 solved the problem for me.

Status: Fixed » Closed (fixed)

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