View Issue Details

IDProjectCategoryView StatusLast Update
0012248mantisbtdb postgresqlpublic2014-12-08 00:34
Reporternomikon Assigned Todregad  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformBSDOSFreeBSDOS Version8.0
Product Version1.1.8 
Target Version1.3.0-beta.1Fixed in Version1.3.0-beta.1 
Summary0012248: Problem updating from 1.1.8 to 1.2.0
Description

(Using PostgreSQL 8.4.4, PHP 5.2.12, on FreeBSD 8.0)

Attempting to upgrade a current 1.1.8 installation to 1.2.0, when is comes to Database upgrade, we set the Mantis DB details (username and pasword). After clicking the 'upgrade' button we get the following page content:

Database Parameters
Upgrade Options
Admin username and password
Setting Database Hostname GOOD
Setting Database Type GOOD
Checking PHP support for database type GOOD
Setting Database Username GOOD
Setting Database Password GOOD
Setting Database Name GOOD
Setting Admin Username GOOD
Setting Admin Password GOOD
Attempting to connect to database as admin BAD
Does administrative user have access to the database? ( Database connection failed )

Looking at the PostgreSQL log, it seems that the upgrading process is attempting to connect to 'template1' database:

Jul 10 08:19:30 postgres[41626]: [2-1] LOG: received connection: host=127.0.0.1 port=55536
Jul 10 08:19:30 postgres[41626]: [3-1] LOG: authorized connection: usuario=mantis database=template1
Jul 10 08:19:30 postgres[41626]: [4-1] FATAL: permission denied to database <<template1>>
Jul 10 08:19:30 postgres[41626]: [4-2] DETAIL: User has no connection privileges.

As far as 'Setting Database Name', 'Setting Admin Username' and 'Setting Admin Password' are all found GOOD, the fault doesn't make sense. It seems there is no reason to attempt to connect with the 'template1' database, for which the Mantis DB owner doesn't have privileges.

Steps To Reproduce

Just following the steps above.

TagsNo tags attached.

Relationships

has duplicate 0011573 closeddregad Cannot upgrade from 1.1.x to 1.2.0 using PostgreSQL and an unprivileged user 
child of 0014398 closeddregad Support for PostgreSQL broken in 1.3 

Activities

jreese

jreese

2010-08-11 13:48

reporter   ~0026270

You mention upgrading to 1.2.0, but that is not the latest version, and I believe there were a few fixes to the upgrade system in 1.2.1 and 1.2.2. Can you please try upgrading directly to 1.2.2 and see if that solves the issue?

nomikon

nomikon

2010-08-11 15:00

reporter   ~0026272

Thanks for your quick answer!

Before sending the report I reviewed the change logs for 1.2.1 and 1.2.2, looking for a possible fix to that issue. Anyway I have just now attemped the upgrade using a fresh 1.2.2 download, and the problem persists. I keep getting the same red warning:

Attempting to connect to database as admin BAD
Does administrative user have access to the database? ( Database connection failed )

The PostgreSQL log shows the same error as well (the Mantis DB owner is trying to connect to 'template1' database.)

jreese

jreese

2010-08-11 15:18

reporter   ~0026274

Could you paste the portion of your config_inc.php here that involves the database connection? Thanks

nomikon

nomikon

2010-08-11 18:46

reporter   ~0026291

Here is:

...

--- Database Configuration ---

$g_hostname = 'localhost';
$g_db_type = 'pgsql';
$g_database_name = 'mantis';
$g_db_username = 'mantis';
$g_db_password = 'xxxxxx';
...

This same DB configuration is running fine in 1.1.8

nomikon

nomikon

2010-08-26 14:09

reporter   ~0026477

Hi, any new about this issue? As far as I can see, the problem is clear:

The admin/install.php script (lines 285 and later) ALWAYS try to do a first connection attempt without specifying a database name. In PostgreSQL this means it will attempt to connect to "template1" database, for which the username defined for the Mantis database has no permissions, resulting in the known error.

I don't fully understand the reason to do two connections, given that the second one would catch any errors. If you want to be able to create the database, it would suffit changing the logic the other way around:

Try connect to the specified database with the normal user and password.
If all goes well, go on.
If not, try to create the database using the administrative user and password.
If all goes well, go on.
If not, show error.

Actually, modifying that code to skip the first connection (just for testing) I'm able to go ahead without the known "Attempting to connect to database as admin BAD" error.

However, beyond that point I'm now stumped again with a new "APPLICATION ERROR 0000401" Database query failed. Error received from database was #-1: ERROR: invalid input syntax for integer: «» for the query: UPDATE mantis_bug_table SET category_id=? WHERE project_id=? AND category=?.

As far as I can remember this is an old known one... Should I open a new ticket for it?

nomikon

nomikon

2010-08-26 14:15

reporter   ~0026478

BTW, as far as this issue is blocking the upgrade, should we raise the category of this ticket up to "block"?

Sander Niemeijer

Sander Niemeijer

2012-10-05 07:08

reporter   ~0033045

I am having the same issue when trying to upgrade from 1.2.8 to 1.2.11 (PostgreSQL 8.4.4, PHP 5.3.2, RHEL 6.0), patching the install.php to include '$f_database_name' in the first call to $g_db->Connect resolved the issue for me.

dregad

dregad

2012-10-16 09:17

developer   ~0033227

Unassigned from jreese as he is no longer actively developing.

dregad

dregad

2014-02-24 15:26

developer   ~0039514

This should be fixed in master branch; if you are able to reproduce the behavior using a nightly build, feel free to reopen the issue.