Bug 697015

Summary: Unable to load PDO-dblib driver on Apache startup
Product: [Fedora] Fedora Reporter: Steven Hadfield <hadfieldster>
Component: httpdAssignee: Joe Orton <jorton>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 16CC: fedora, jkaluza, jorton, pahan, rpm, scott
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-14 02:52:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steven Hadfield 2011-04-15 15:38:21 UTC
Description of problem:
When I startup Apache with mod_php, the DBLIB PDO driver is not available and I see an error in the Apache log file stating that it was unable to load the library. Doing some searching around, I was able to find a solution for Ubuntu that also works for Fedora: http://ubuntuforums.org/showthread.php?t=1630572

The core problem (AFAICT) is that pdo_dblib.ini comes before pdo.ini in the '/etc/php.d' directory. The result of this is that it is trying to load PDO-DBLIB before PDO has been loaded.
The solution mentioned on the Ubuntu forum is to rename pdo.ini to something that will force it to come before pdo_dblib.ini.
I changed '/etc/php.d/php.ini' to 'pdo_0.ini' and that has seemed to solve the problem for me.

Version-Release number of selected component (if applicable):
php-pdo-5.3.6-3.x86_64.fc16
php-mssql-5.3.6-3.x86_64.fc16
I know that I've had this problem with previous versions as well.

How reproducible:
Sometimes. Unfortunately I haven't been able to trace down this issue more than that. I'm wondering if this hasn't been more of an issue because of warm reloading of Apache leading to PDO already being loaded when Apache tries to load PDO_DBLIB.

Steps to Reproduce:
1. Install php-mssql
2. Restart Apache (not graceful)
3. 'echo phpinfo();' from a PHP page served by Apache
  
Actual results:
dblib not displayed in list of PDO drivers

This warning shows up in the Apache error log after the restart:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_dblib.so' - /usr/lib64/php/modules/pdo_dblib.so: undefined symbol: php_pdo_register_driver in Unknown on line 0


Expected results:
dblib displayed in list of PDO drivers

(No error)

Additional info:

-I can get dblib to show up in the list of PDO drivers when I do a php -i from the CLI, but not in Apache unless I perform the fix mentioned above.
-I have the same problem with loading PDO-Informix (hand rolled) as pdo_informix.ini comes before pdo.ini. Again, the problem is solved when the name of pdo.ini is changed to come before it.

Comment 1 Joe Orton 2011-04-15 15:49:54 UTC
By a restart, do you mean a SIGHUP of a running daemon (service httpd reload) rather than a stop and start?

The ini files are alpha-sorted before being parsed so if the ordering is correct, and it seems to be, it should work.

Comment 2 Steven Hadfield 2011-04-20 16:26:53 UTC
I ran it a few different ways, but it seems to always come up now, regardless of whether I use service httpd stop/start, reload, restart, or graceful. 
The reason why I said specifically not graceful before is because I wasn't sure if that was a factor in why this problem hadn't always been a problem for me.

It seems that the alpha ordering is not making a distinction between '.' and '_'.
When I do ls -l /etc/php.d:
...
-rw-r--r--. 1 root root   59 Apr  4 11:55 pdo_dblib.ini
-rw-r--r--. 1 root root   65 Jul 20  2010 pdo_informix.ini
-rw-r--r--. 1 root root   47 Apr  4 11:55 pdo.ini
-rw-r--r--. 1 root root   59 Apr  4 11:55 pdo_mysql.ini
-rw-r--r--. 1 root root   57 Apr  4 11:55 pdo_odbc.ini
-rw-r--r--. 1 root root   59 Apr  4 11:55 pdo_pgsql.ini
-rw-r--r--. 1 root root   61 Apr  4 11:55 pdo_sqlite.ini
...

I realize that the files are not necessarily loaded in the same order as ls displays them, but it seems to coincide that way (I haven't looked at the source code to tell how it does it).

The ordering above does not work for me (I see the warnings in the error_log), where as the following does work (no warnings):
...
-rw-r--r--. 1 root root   47 Apr  4 11:55 pdo_0.ini
-rw-r--r--. 1 root root   59 Apr  4 11:55 pdo_dblib.ini
-rw-r--r--. 1 root root   65 Jul 20  2010 pdo_informix.ini
-rw-r--r--. 1 root root   59 Apr  4 11:55 pdo_mysql.ini
-rw-r--r--. 1 root root   57 Apr  4 11:55 pdo_odbc.ini
-rw-r--r--. 1 root root   59 Apr  4 11:55 pdo_pgsql.ini
-rw-r--r--. 1 root root   61 Apr  4 11:55 pdo_sqlite.ini
...

Comment 3 Remi Collet 2011-04-20 17:57:15 UTC
File order is environment dependant

# LANG=C ls /etc/php.d/pdo*
/etc/php.d/pdo.ini
/etc/php.d/pdo_dblib.ini
/etc/php.d/pdo_firebird.ini
/etc/php.d/pdo_mysql.ini
/etc/php.d/pdo_oci.ini
/etc/php.d/pdo_odbc.ini
/etc/php.d/pdo_pgsql.ini
/etc/php.d/pdo_sqlite.ini

# LANG=fr_FR.utf8 ls /etc/php.d/pdo*
/etc/php.d/pdo_dblib.ini
/etc/php.d/pdo_firebird.ini
/etc/php.d/pdo.ini
/etc/php.d/pdo_mysql.ini
/etc/php.d/pdo_oci.ini
/etc/php.d/pdo_odbc.ini
/etc/php.d/pdo_pgsql.ini
/etc/php.d/pdo_sqlite.ini

So it seems you have change the value of HTTPD_LANG in /etc/sysconfig/httpd

Comment 4 Steven Hadfield 2011-04-20 18:40:57 UTC
My user environment is en_US.utf8, but the /etc/sysconfig/httpd does not have LANG set. So I guess the problem is that when I (re)start the Apache service, it's using my LANG environment variable instead of the default since LANG is defined in the environment.

I explicitly set HTTPD_LANG=C in /etc/sysconfig/httpd, but I'm still seeing the warnings in the error_log after restarting Apache.

Comment 5 Remi Collet 2012-02-02 16:47:00 UTC
Re-affecting to F16 and to httpd

I reproduce the bug which seems specific to systemd (never encounter this with SysV script)

Workaround found, in /lib/systemd/system/httpd.service

Environment=LANG=C


@Steven : can you confirm this workaround also work for you ?

Comment 6 Steven Hadfield 2012-02-14 16:52:14 UTC
Unfortunately I no longer have the environment where I was seeing the issue. My current Fedora 16 install does not seem to have this problem, but I know I don't have everything the same way I did before.

Comment 7 Remi Collet 2012-04-30 17:58:04 UTC
@Joe: with sysV init script we have

in /etc/sysconfig/httpd
  #HTTPD_LANG=C 

And in 
  HTTPD_LANG=${HTTPD_LANG-"C"}
  LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

So httpd is launch with choosen LANG (default to C)

With systemd, we don't have any solution to set LANG correctly, which explain this issue

Proposal:

Move, in /etc/sysconfig/httpd
From
  #HTTPD_LANG=C
To
  # Be aware than other locale could change extension load order
  LANG=C

And we'll get the same behavior

Comment 8 Joe Orton 2012-04-30 20:19:39 UTC
Ah, good catch Remi - yes, that'd be it.  That changes already done in f17/f18.  For f16 it's perhaps safer to make the change directly in the .service script, otherwise the init script itself will change LANG which is probably not desirable (the service script output is i18n'ed, I think?)

Comment 9 Joe Orton 2012-04-30 20:21:13 UTC
"init script output" I meant there.

Comment 11 Fedora End Of Life 2013-01-17 01:44:03 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 12 Fedora End Of Life 2013-02-14 02:53:01 UTC
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.