PHP :: Bug #75595 :: Database connect
php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75595 Database connect
Submitted: 2017-11-30 13:15 UTC Modified: 2017-11-30 15:39 UTC
From: markus at prepaid-order dot com Assigned:
Status: Open Package: PDO MySQL
PHP Version: 7.1.12 OS: ubuntu 16.04
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-11-30 13:15 UTC] markus at prepaid-order dot com
Description:
------------
simple mariadb PDO connect and give result after success...

when Database is available all worked fine.... shut down DB instance manual and host is not available call simple php script with this function...

if Database is down catch block will not work and php is working and after that following Message appear.

Fatal error: Allowed memory size of 629145600 bytes exhausted (tried to allocate 20480 bytes)

my php function shows like this.



the Code worked before,source code have never changed.
tested with arbitrary php_memory limit,but the issue is still available...

testet with php 5.6,7.0,7.1 (default)...

it works fine with 7.1,but have no idea...

timeout array in PDO constructor have also removed...


Test script:
---------------
> function getDBConnection()
> {
>     global $pdo;
>     try {
>         if ($pdo == null)
>             $pdo = new PDO(
>            
>                 'mysql:host=databaseHost;dbname=someDatabase;charset=utf8mb4',
>                 'removed',
>                 'removed_too'
>             );
>     } catch (Exception $ex) {
>         
>         generateErrorPlistWithFailReason(ErrorCodes::DATABASE_IS_DOWN, 
>         exit();
>     }
>     return $pdo;
> }



Expected result:
----------------
resource result and or result from catch block (if databse is down/notavailable)...

Actual result:
--------------
after timeout 

Fatal error: Allowed memory size of 629145600 bytes exhausted (tried to allocate 20480 bytes)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-30 14:48 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-11-30 14:48 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

According to your description the problem would be somewhere within generateErrorPlistWithFailReason...
 [2017-11-30 15:39 UTC] markus at prepaid-order dot com
-Status: Feedback +Status: Open
 [2017-11-30 15:39 UTC] markus at prepaid-order dot com
hi,
this simple function is inside of any php class.
remember (it works) fine !!!! but the catch block never called when pdo resource is null or timed out.

this is only the connection to connect the database.You can call any small sql statement no matter.

this works fine (only database is online an available). You can stop the mysql instance via /etcInit.d/mysql stop
you can make any connection see my PDO DSN string select any table or sql statement,
hope you can see the error too... please shut down the database instance and call the php script / connection again,aou will see the error appear.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Aug 19 14:01:25 2018 UTC