Bug 520532 - Checksetup.pl fails when adding foreign keys to 3.4 database during upgrade
Summary: Checksetup.pl fails when adding foreign keys to 3.4 database during upgrade
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Bugzilla
Classification: Community
Component: Bugzilla General
Version: 3.4
Hardware: All
OS: Linux
low
medium vote
Target Milestone: ---
Assignee: Tony Fu
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 520523
TreeView+ depends on / blocked
 
Reported: 2009-08-31 23:01 UTC by David Lawrence
Modified: 2013-06-24 04:08 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-10-19 07:00:08 UTC


Attachments (Terms of Use)
Adding FKs information into bz_schema table (1.85 KB, text/plain)
2009-10-13 03:55 UTC, Tony Fu
dkl: review+
tfu: review? (nelhawar)
Details

Description David Lawrence 2009-08-31 23:01:53 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 David Lawrence 2009-08-31 23:08:26 UTC
Sorry I messed up the description on the initial bug submission. Here is the rest.

Adding foreign key: attach_data.id -> attachments.attach_id...
DBD::mysql::db do failed: Can't create table './bugs34/#sql-e63_3f8c.frm' (errno: 121) [for Statement "ALTER TABLE attach_data ADD 
     CONSTRAINT fk_attach_data_id_attachments_attach_id FOREIGN KEY (id)
     REFERENCES attachments(attach_id)
      ON UPDATE CASCADE ON DELETE CASCADE"] at Bugzilla/DB.pm line 515
	Bugzilla::DB::bz_add_fk('Bugzilla::DB::Mysql=HASH(0x1c290cd0)', 'attach_data', 'id', 'HASH(0x1c2ffd70)') called at Bugzilla/DB.pm line 450
	Bugzilla::DB::bz_setup_foreign_keys('Bugzilla::DB::Mysql=HASH(0x1c290cd0)') called at Bugzilla/Install/DB.pm line 623
	Bugzilla::Install::DB::update_table_definitions('HASH(0x18ec7c70)') called at ./checksetup.pl line 192


This error is usually caused by the data types not matching between the foreign key of the two tables. So we need to make sure they match up in the database and the Bugzilla/DB/Schema.pm files.

Comment 2 Tony Fu 2009-10-06 05:56:33 UTC
Dave,

I found out that this error is not caused by the data type (the attachments.attach_id matches attach_data.id in our bugs database).  It is because the MySQL doesn't allow adding a foreign key if it is already existing.  When we run the checksetup.pl, checksetup.pl calls Bugzilla::DB::bz_setup_foreign_keys() to add all generic FKs (non red hat specific FKs), while all generic FKs are already there and this error happens at the first FK generation point (Attach_data.id -> attachments.attach_id).

I can't find an easy way to fix this issue (upstream has a similar bug https://bugzilla.mozilla.org/show_bug.cgi?id=377432).  But if only for my upgrade, we can just delete the bz_setup_foreigh_keys() fuction, 'cause all FKs have been added into our db already.


Tony

Comment 3 Tony Fu 2009-10-13 03:55:33 UTC
Created attachment 364542 [details]
Adding FKs information into bz_schema table

Comment 4 David Lawrence 2009-10-13 18:14:07 UTC
Comment on attachment 364542 [details]
Adding FKs information into bz_schema table

Looks good Tony. Although you do not need the 'use DBI;'. 

Submit a ticket to eng-systems asking for them to run this script on the live web app from the document root directly.

Dave

Comment 5 Tony Fu 2009-10-19 07:00:08 UTC
Have run this script to update bz_schema table on production db.

And this bug should have been fixed.


Note You need to log in before you can comment on or make changes to this bug.