Closed Bug 912479 Opened 6 years ago Closed 6 years ago

merge-users.pl causes foreign key constraint errors in the user-profile tables

Categories

(bugzilla.mozilla.org :: Extensions, defect)

Production
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: glob, Assigned: glob)

References

Details

Attachments

(1 file)

when justdave's accounts were merged, the following error occurred:

DBD::mysql::st execute failed: Duplicate entry '10297-' for key 'profiles_statistics_products_idx' [for Statement "UPDATE profiles_statistics_products SET user_id = ? WHERE user_id = ?" with ParamValues: 0=10297, 1=198524] at ./contrib/merge-users.pl line 213.

what happened is the merger-users script uses foreign keys to determine which tables to update, and is causing duplicate entries in our statistics tables.

i'll add two hooks to that script - one before the tables are touched (where the user-profile ext can delete all the generated data), and one after (for user-profile to regenerate the data).
Summary: Please merge justdave@mozilla.com into justdave@bugzilla.org → merge-users.pl causes foreign key constraint errors in the user-profile tables
Attached patch 912479_1.patchSplinter Review
Attachment #799499 - Flags: review?(dkl)
Another option and possible future-proofing would be to make use of something like "ON DUPLICATE IGNORE" or "ON DUPLICATE REPLACE" if supported and ass appropriate for the column in question.  Which to use might need to be defined in the schema table.
Comment on attachment 799499 [details] [diff] [review]
912479_1.patch

Review of attachment 799499 [details] [diff] [review]:
-----------------------------------------------------------------

This solution is better I think as it is database agnostic. Code looks fine and works as expected. r=dkl
Attachment #799499 - Flags: review?(dkl) → review+
Committing to: bzr+ssh://bjones%40mozilla.com@bzr.mozilla.org/bmo/4.2/
modified contrib/merge-users.pl
modified extensions/UserProfile/Extension.pm
Committed revision 8985.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Component: Extensions: UserProfile → Extensions
You need to log in before you can comment on or make changes to this bug.