Database Reconnect failure, PMF 2.6.5

Please report bugs here!

Moderator: Thorsten

Post Reply
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Database Reconnect failure, PMF 2.6.5

Post by dajoker »

It appears that PMF is fairly clever and either it or PHP natively is maintaining a pool of connections to PostgreSQL which is really neat; however, when the database is restarted and the web server is not an error shows up within the browser indicating there was a failure with the database. I haven't waited for a long time to see if that resolves itself but it'd be nice if the PHP code could handle that. I have not looked into the cause of this at all (no time, not critical to me yet, and the workaround of restarting Apache's httpd is easy for now) but I'll try to if/when I get time.

Error:

phpMyFAQ notice [8]: pg_query(): Cannot set connection to blocking mode in Pgsql.php on line 91
phpMyFAQ notice [8]: Unknown: Cannot set connection to blocking mode in Unknown on line 0

Note that to duplicate this after a fresh install I had to login to the administrative pages (I also logged out but I do not think that matters). Once logged out I just refreshed the main page and had the error above.

Thanks.
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Re: Database Reconnect failure, PMF 2.6.5

Post by dajoker »

It looks like time may solve this problem, just for the record. Haven't tested extensively but I think I'm seeing that as well.
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Database Reconnect failure, PMF 2.6.5

Post by Thorsten »

Hi,

we could try to use the pg_connection_busy() function for checking if the connection is blocked. I have to read more about this blocking connection in PostgreSQL because I never heard about it.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
bram
Posts: 19
Joined: Mon Aug 16, 2010 12:54 pm

Re: Database Reconnect failure, PMF 2.6.5

Post by bram »

The most likely reason that this happens is because you have pgsql.auto_reset_persistent set to Off.
This causes php to reuse the connection without testing if the connection is still alive/active.

When something happend on the database server that closes the connection (restart of database, idle timeout on session, ..) then this can result in errors.

Errors I've seen before: (after the connection was killed by the database server because it was idle for 1 hour):

Code: Select all

phpMyFAQ notice [8]: pg_query() [function.pg-query]: Cannot set connection to blocking mode in Pgsql.php on line 82

phpMyFAQ notice [8]: pg_query() [function.pg-query]: Cannot set connection to blocking mode in Pgsql.php on line 95

Fatal error: Uncaught exception 'Exception' with message 'Error while fetching result: FATAL: terminating connection due to administrator command server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.' in /opt/supfaq/inc/PMF_DB/Pgsql.php:143 Stack trace: #0 /opt/supfaq/inc/Configuration.php(108): PMF_DB_Pgsql->fetchAll(false) #1 /opt/supfaq/inc/Init.php(103): PMF_Configuration->getAll() #2 /opt/supfaq/admin/index.php(48): require_once('/opt/supfaq/inc...') #3 {main} thrown in /opt/supfaq/inc/PMF_DB/Pgsql.php on line 143

phpMyFAQ notice [8]: Unknown: Cannot set connection to blocking mode in Unknown on line 0
This can be fixed by:
1. enabling pgsql.auto_reset_persistent (by changing your php.ini or by using 'php_admin_flag pgsql.auto_reset_persistent On' in your apache configuration.)
2. disabling pgsql.allow_persistent (this disables persistant connetions)
Post Reply