Bug 520532

Summary: Checksetup.pl fails when adding foreign keys to 3.4 database during upgrade
Product: [Community] Bugzilla Reporter: David Lawrence <dkl>
Component: Bugzilla GeneralAssignee: Tony Fu <tfu>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: 3.4   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-10-19 07:00:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 520523    
Attachments:
Description Flags
Adding FKs information into bz_schema table dkl: review+, tfu: review? (nelhawar)

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.