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

RESOLVED FIXED in Bugzilla 3.6

Status

()

defect
--
major
RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: imcguire, Assigned: mkanat)

Tracking

({regression})

Dependency tree / graph
Bug Flags:
approval +
approval3.6 +

Details

Attachments

(1 attachment)

Reporter

Description

9 years ago
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

Updated

9 years ago
Version: unspecified → 3.6
Assignee

Comment 1

9 years ago
Those *do* have a default value of 0, normally. Perhaps you had a bad upgrade in the past or modified your database manually somehow?
Reporter

Comment 2

9 years ago
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.
Assignee

Comment 3

9 years ago
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: 9 years ago
Resolution: --- → INVALID

Comment 4

9 years ago
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 → ---
Assignee

Comment 6

9 years ago
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.
Assignee

Updated

9 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee

Updated

9 years ago
Assignee: installation → mkanat
Target Milestone: --- → Bugzilla 3.6
Assignee

Comment 7

9 years ago
Posted 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+
Assignee

Updated

9 years ago
Flags: approval3.6+
Flags: approval+
Assignee

Updated

9 years ago
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
Assignee

Comment 8

9 years ago
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: 9 years ago9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.