Bug 1409720 - checksetup.pl is broken
Summary: checksetup.pl is broken
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Bugzilla
Classification: Community
Component: Database
Version: 5.0
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: 5.0
Assignee: Jeff Fearn 🐞
QA Contact: tools-bugs
URL:
Whiteboard:
: 1409968 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-03 06:56 UTC by Yuxiang Zhu
Modified: 2018-12-09 06:29 UTC (History)
4 users (show)

Fixed In Version: 5.0.3.rh28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-04 04:20:33 UTC
Embargoed:


Attachments (Terms of Use)

Description Yuxiang Zhu 2017-01-03 06:56:43 UTC
Description of problem:
rh-database-update.pl is broken in Bugzilla 5.

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

Steps to Reproduce:
Running `checksetup.pl` or `rh-database-update.pl` against an empty DB will get the following error:

DBD::Pg::db selectcol_arrayref failed: ERROR:  column forn.value does not exist
LINE 3:                 ON tabl.value = forn.value
                                        ^ [for Statement "SELECT DISTINCT tabl.value 
           FROM bug_dependent_products AS tabl LEFT JOIN dependent_products AS forn
                ON tabl.value = forn.value
          WHERE forn.value IS NULL
                AND tabl.value IS NOT NULL"]
<pre>
 at Bugzilla/DB.pm line 1610.
        Bugzilla::DB::_check_references('Bugzilla::DB::Pg=HASH(0x9885f60)', 'bug_dependent_products', 'value', 'HASH(0xcb691c0)') called at Bugzilla/DB.pm line 701
        Bugzilla::DB::bz_add_fks('Bugzilla::DB::Pg=HASH(0x9885f60)', 'bug_dependent_products', 'HASH(0xf764b08)') called at Bugzilla/DB.pm line 690
        Bugzilla::DB::bz_add_fk('Bugzilla::DB::Pg=HASH(0x9885f60)', 'bug_dependent_products', 'value', 'HASH(0xcb691c0)') called at Bugzilla/Install/DB.pm line 3245
        Bugzilla::Install::DB::_add_foreign_keys_to_multiselects() called at Bugzilla/Install/DB.pm line 545
        Bugzilla::Install::DB::update_table_definitions('HASH(0x2bc4bd8)') called at ./checksetup.pl line 173

</pre> at Bugzilla/DB.pm line 1610.

Additional info:

This is because Bugzilla::DB::bz_add_fk() tries to add a foreign key that references a nonexistent column 'value' in table 'dependent_products'.

Comment 1 Jeff Fearn 🐞 2017-01-08 23:48:42 UTC
What is an "empty database", and how do you get it?

The dev CI tests create a brand new database from scratch for every change set so it's unlikely a problem with the code.

Comment 2 Yuxiang Zhu 2017-01-09 02:58:48 UTC
(In reply to Jeff Fearn from comment #1)
> What is an "empty database", and how do you get it?

Sorry, I mean "new database from scratch", without any tables.

> 
> The dev CI tests create a brand new database from scratch for every change
> set so it's unlikely a problem with the code.

That's weird.
I tried upgrading the DB schema from BZ4 to BZ5 using checksetup.pl. It works fine. But the error above occurred if I against running it against a blank database.

Comment 3 Rony Gong 🔥 2017-01-09 04:56:07 UTC
After generate localconfig by checksetup.pl, then set the db to a non_exist database in localconfig
$db_name = 'bugs_test2';


Then rerun checksetup.pl
[root@bz-web bugzilla]# ./checksetup.pl 
* This is Bugzilla 5.0.3.rh21 on perl 5.16.3
* Running on Linux 3.10.0-327.10.1.el7.x86_64 #1 SMP Sat Jan 23 04:54:55 EST 2016
..........
Reading ./localconfig...
Checking for               DBD-Pg (v2.7.0)    ok: found v3.5.3 

Deep recursion on subroutine "Bugzilla::dbh" at Bugzilla/Mailer.pm line 110, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::dbh_main" at Bugzilla.pm line 576, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::connect_main" at Bugzilla.pm line 580, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::_connect" at Bugzilla/DB.pm line 124, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::Pg::new" at Bugzilla/DB.pm line 139, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::db_new" at Bugzilla/DB/Pg.pm line 58, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::Mailer::MessageToMTA" at Bugzilla/DB.pm line 1402, <DATA> line 747.


I think this may related to bug 1409968

Comment 4 Jeff Fearn 🐞 2017-01-17 10:23:26 UTC
*** Bug 1409968 has been marked as a duplicate of this bug. ***

Comment 5 Jeff Fearn 🐞 2017-01-17 10:28:45 UTC
Have you enabled check_db in localconfig and granted the bugzilla user the right to create databases?

The first is something we always disable, and the second is considered poor security practice, neither should not be used for testing releases destined for production.

Comment 6 Rony Gong 🔥 2017-01-18 01:51:48 UTC
(In reply to Jeff Fearn from comment #5)
> Have you enabled check_db in localconfig and granted the bugzilla user the
> right to create databases?

1.$db_check=0    This means enabled
2.not yet grant the createdb permission

but after grant createdb permission, same error as before.

> 
> The first is something we always disable, and the second is considered poor
> security practice, neither should not be used for testing releases destined
> for production.

Comment 7 Jeff Fearn 🐞 2017-02-14 01:30:05 UTC
(In reply to Rony Gong from comment #6)
> (In reply to Jeff Fearn from comment #5)
> > Have you enabled check_db in localconfig and granted the bugzilla user the
> > right to create databases?
> 
> 1.$db_check=0    This means enabled

No, this means disabled, it has to be 1 to enable it.

> 2.not yet grant the createdb permission
> 
> but after grant createdb permission, same error as before.

Yes, it won't try to create the DB unless you set $db_check=1.

Comment 8 Rony Gong 🔥 2017-02-14 05:38:03 UTC
After set "$db_check=1" ,it still show error:

Reading ./localconfig...
Checking for               DBD-Pg (v2.7.0)    ok: found v3.5.3 
Checking for           PostgreSQL (v8.03.0000) ok: found v09.02.1500 
Checking for               DBD-Pg (v2.19.3)   ok: found v3.5.3 

Deep recursion on subroutine "Bugzilla::DB::connect_main" at Bugzilla.pm line 580, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::_connect" at Bugzilla/DB.pm line 124, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::Pg::new" at Bugzilla/DB.pm line 139, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::DB::db_new" at Bugzilla/DB/Pg.pm line 58, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::Mailer::MessageToMTA" at Bugzilla/DB.pm line 1402, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::dbh" at Bugzilla/Mailer.pm line 110, <DATA> line 747.
Deep recursion on subroutine "Bugzilla::dbh_main" at Bugzilla.pm line 576, <DATA> line 747.

Comment 9 Rony Gong 🔥 2017-03-21 06:58:32 UTC
Tested on QA environment(5.0.3-rh25)
Result: Pass
Steps:
After set "$db_check=1" ,it works well and could create tables now.


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