Closed Bug 561379 Opened 14 years ago Closed 14 years ago

Upgrading from 3.4.4 to 3.6 fails with ORA-01400, because group_control_map.entry is NOT NULL and has no DEFAULT at that point

Categories

(Bugzilla :: Installation & Upgrading, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
Bugzilla 3.6

People

(Reporter: imcguire, Assigned: mkanat)

References

Details

(Keywords: regression)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Build Identifier: 3.6

I was trying to upgrade my Bugzilla 3.4.4 installation to 3.6.  My installation is using an Oracle 11.2 database.  The upgrade failed while running checksetup.pl with:

 DBD::Oracle::db do failed: ORA-01400: cannot insert NULL into ("BUGS"."GROUP_CONTROL_MAP"."ENTRY") (DBD ERROR: OCIStmtExecute) [for Statement "INSERT INTO group_control_map (group_id, product_id, membercontrol, othercontrol) VALUES (?, ?, ?, ?)"] at Bugzilla/DB/Oracle.pm line 401
        Bugzilla::DB::Oracle::do('undef', 'INSERT INTO group_control_map (group_id, product_id, memberco...', 'undef', 14, 3, 1, 0) called at Bugzilla/Install/DB.pm line 1915
        Bugzilla::Install::DB::_setup_usebuggroups_backward_compatibility() called at Bugzilla/Install/DB.pm line 282
        Bugzilla::Install::DB::update_table_definitions('HASH(0x193bb2b0)') called at ./checksetup.pl line 198

To work around this problem and continue with the upgrade I modified the GROUP_CONTROL_MAP giving a default value of 0 for the CANEDIT and ENTRY columns.


Reproducible: Didn't try
Version: unspecified → 3.6
Those *do* have a default value of 0, normally. Perhaps you had a bad upgrade in the past or modified your database manually somehow?
I may be looking in the wrong place; but, in the file Schema.pm I see a definition for the group_control_map table which differs between 3.4 and 3.6.

For 3.4.4:
entry         => {TYPE => 'BOOLEAN', NOTNULL => 1},

For 3.6:
entry         => {TYPE => 'BOOLEAN', NOTNULL => 1,
                              DEFAULT => 'FALSE'},

My installation started as 3.4.1 and was previously upgraded to 3.4.4 before I attempted to move to 3.6.  There may have been some corruption with my installation because I can't even find the group_control_map table in my database export from 3.4.4.
Oh actually, yeah, there must have been a serious problem with your database dump, because _setup_usebuggroups_backward_compatibility should never run on an Oracle database.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
I ran into this when upgrading an installation from 3.4 to 3.6:

DBD::Pg::db do failed: ERROR:  null value in column "entry" violates not-null constraint [for Statement "INSERT INTO group_control_map (group_id, product_id, membercontrol, othercontrol) VALUES (?, ?, ?, ?)"] at Bugzilla/Install/DB.pm line 1915
	Bugzilla::Install::DB::_setup_usebuggroups_backward_compatibility() called at Bugzilla/Install/DB.pm line 282
	Bugzilla::Install::DB::update_table_definitions('HASH(0x139a860)') called at ./checksetup.pl line 198

The database did not have default values for the 'entry' or 'canedit' fields:

bugzilla-3.6=> \d group_control_map

        Table "public.group_control_map"
     Column     |   Type   |     Modifiers      
----------------+----------+--------------------
 group_id       | integer  | not null
 product_id     | integer  | not null
 entry          | smallint | not null
 membercontrol  | smallint | not null
 othercontrol   | smallint | not null
 canedit        | smallint | not null
 editcomponents | smallint | not null default 0
 editbugs       | smallint | not null default 0
 canconfirm     | smallint | not null default 0
Indexes:
    "group_control_map_product_id_idx" UNIQUE, btree (product_id, group_id)
    "group_control_map_group_id_idx" btree (group_id)
Foreign-key constraints:
    "fk_group_control_map_group_id_groups_id" FOREIGN KEY (group_id) REFERENCES groups(id) ON UPDATE CASCADE ON DELETE CASCADE
    "fk_group_control_map_product_id_products_id" FOREIGN KEY (product_id) REFERENCES products(id) ON UPDATE CASCADE ON DELETE CASCADE

Adding the default values and re-trying allowed the upgrade to proceed without errors.

Adding CCs as requested by wicked on #mozwebtools
I can see how this problem can happen. In Bugzilla/Install/DB.pm line 286 the _setup_usebuggroups_backward_compatibility() sub is called, which assumes entry column has a default (and doesn't specify a value for it when inserting values) but unfortunately the default is only added to the entry column of group_control_map in line 574.

This problem is only triggered when group_control_map is empty because code in the _setup_usebuggroups_backward_compatibility sub is only run in that case.

This seems to be a regression from bug 478972, which removed entry from the INSERT and added the defaults.
Status: RESOLVED → UNCONFIRMED
Depends on: 478972
Keywords: regression
OS: Linux → All
Hardware: x86_64 → All
Resolution: INVALID → ---
The most pertinent question is--why is the usebuggroups Install::DB sub running on Oracle? That code was from long before we had Oracle support. So if we fix that code to only run when it should *actually* run, then we won't hit this problem.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: installation → mkanat
Target Milestone: --- → Bugzilla 3.6
Attached patch v1Splinter Review
Okay, this patch should fix the problem, by simply not running that code on any DB other than MySQL.
Attachment #448448 - Flags: review+
Flags: approval3.6+
Flags: approval+
Summary: Upgrading from 3.4.4 to 3.6 fails with ORA-01400 → Upgrading from 3.4.4 to 3.6 fails with ORA-01400, because group_control_map.entry is NOT NULL and has no DEFAULT at that point
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/Install/DB.pm
Committed revision 7202.

Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/3.6/
modified Bugzilla/Install/DB.pm
Committed revision 7105.
Status: NEW → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: