Last Comment Bug 561379 - 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
: Upgrading from 3.4.4 to 3.6 fails with ORA-01400, because group_control_map.e...
Status: RESOLVED FIXED
: regression
Product: Bugzilla
Classification: Server Software
Component: Installation & Upgrading (show other bugs)
: 3.6
: All All
: -- major (vote)
: Bugzilla 3.6
Assigned To: Max Kanat-Alexander
: default-qa
Mentors:
Depends on: 478972
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-23 08:48 PDT by Ian McGuire
Modified: 2010-05-31 20:48 PDT (History)
5 users (show)
mkanat: approval+
mkanat: approval3.6+
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
v1 (1.12 KB, patch)
2010-05-31 20:33 PDT, Max Kanat-Alexander
mkanat: review+
Details | Diff | Review

Description Ian McGuire 2010-04-23 08:48:46 PDT
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
Comment 1 Max Kanat-Alexander 2010-04-23 10:22:27 PDT
Those *do* have a default value of 0, normally. Perhaps you had a bad upgrade in the past or modified your database manually somehow?
Comment 2 Ian McGuire 2010-04-23 11:19:45 PDT
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.
Comment 3 Max Kanat-Alexander 2010-04-23 14:47:00 PDT
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.
Comment 4 sam morris 2010-05-31 12:52:28 PDT
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
Comment 5 Teemu Mannermaa (:wicked) 2010-05-31 13:00:16 PDT
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.
Comment 6 Max Kanat-Alexander 2010-05-31 20:03:29 PDT
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.
Comment 7 Max Kanat-Alexander 2010-05-31 20:33:03 PDT
Created attachment 448448 [details] [diff] [review]
v1

Okay, this patch should fix the problem, by simply not running that code on any DB other than MySQL.
Comment 8 Max Kanat-Alexander 2010-05-31 20:48:25 PDT
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.

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