Обсуждение: SQLSTATE[08006] [7] server closed the connection unexpectedly

Поиск
Список
Период
Сортировка

SQLSTATE[08006] [7] server closed the connection unexpectedly

От
Yvon Thoraval
Дата:
I do have a strange probleme when connecting to a database thru php using PDO.
When connecting to the php script thru a browser i get the following error :
HTTP 500 (Internal Server Error) 

Not really informative, then i've tried the php script thru Command Line where i get :
yt@D620 /home/yt/Sites/yt_tests $ php index.php
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.' in /home/yt/Sites/yt_tests/index.php:75
Stack trace:
#0 /home/yt/Sites/yt_tests/index.php(75): PDO->__construct('pgsql:dbname=yt...', 'yt', 'yvon5533')
#1 {main}
  thrown in /home/yt/Sites/yt_tests/index.php on line 75
zsh: exit 255   php index.php

Line 75 being :
$db = new PDO("pgsql:dbname=$dbname;host=$host;", $username, $password );

I should say i do NOT have any prob when connecting directly to this database using :
$ psql -h <IPV4 or IPV6 of the PostgreSQL server> -U yt -d yt_tests

I'm stuck, i don't see any way to debugg that prob.


--
Yvon


Re: SQLSTATE[08006] [7] server closed the connection unexpectedly

От
"Albe Laurenz"
Дата:
Yvon Thoraval wrote:
> I do have a strange probleme when connecting to a database thru php using PDO.
> When connecting to the php script thru a browser i get the following error :
> HTTP 500 (Internal Server Error)
> 
> 
> Not really informative, then i've tried the php script thru Command Line where i get :
> yt@D620 /home/yt/Sites/yt_tests $ php index.php
> PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] server closed
> the connection unexpectedly
>     This probably means the server terminated abnormally
>     before or while processing the request.' in /home/yt/Sites/yt_tests/index.php:75
> Stack trace:
> #0 /home/yt/Sites/yt_tests/index.php(75): PDO->__construct('pgsql:dbname=yt...', 'yt', 'yvon5533')
> #1 {main}
>   thrown in /home/yt/Sites/yt_tests/index.php on line 75
> zsh: exit 255   php index.php
> 
> 
> Line 75 being :
> $db = new PDO("pgsql:dbname=$dbname;host=$host;", $username, $password );
> 
> I should say i do NOT have any prob when connecting directly to this database using :
> $ psql -h <IPV4 or IPV6 of the PostgreSQL server> -U yt -d yt_tests
> 
> I'm stuck, i don't see any way to debugg that prob.

Is this repeatable?

That message normally means that the server process crashed.
What is in the PostgreSQL server log file?
You may want to set log_statement='all' in postgresql.conf
to get more context.

Yours,
Laurenz Albe

Re: SQLSTATE[08006] [7] server closed the connection unexpectedly

От
Yvon Thoraval
Дата:


2012/9/14 Albe Laurenz <laurenz.albe@wien.gv.at>

Is this repeatable?

YES, may be i didn't mention that about the same config on another computer running mac OS X, works very well with same php script. Also this php script was working 2 months ago...
i suspect something had changed on Xubuntu within pdo, php and psql ?
 
That message normally means that the server process crashed.

I don't think so because even after this error I'm still able to connect to the db that way :
 $ psql -h localhost -U yt -d yt_tests
Password for user yt: 
psql (9.1.5)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

yt_tests=> select * from weather;
     city      | temp_lo | temp_hi | prcp |    date    
---------------+---------+---------+------+------------
 San Francisco |      46 |      50 | 0.25 | 1994-11-27
 Hayward       |      37 |      54 |      | 1994-11-29
 San Francisco |      43 |      57 |    0 | 1994-11-29
(3 rows)

yt_tests=> \q

What is in the PostgreSQL server log file?

Nothing mentionned about this prob.
 
You may want to set log_statement='all' in postgresql.conf

OK, fine thanks, I'll do that ASAP and repost.
 
to get more context.

Yours,
Laurenz Albe



--
Yvon


Re: SQLSTATE[08006] [7] server closed the connection unexpectedly

От
Yvon Thoraval
Дата:


2012/9/14 Albe Laurenz <laurenz.albe@wien.gv.at>
Yvon Thoraval wrote:
You may want to set log_statement='all' in postgresql.conf

i did this change , restart PostgreSQL and test again, with the same error, however postgres log didn't report any error, as far as i understand the log :
 
2012-09-14 18:43:14 CEST LOG:  received fast shutdown request
2012-09-14 18:43:14 CEST LOG:  aborting any active transactions
2012-09-14 18:43:14 CEST LOG:  autovacuum launcher shutting down
2012-09-14 18:43:14 CEST LOG:  shutting down
2012-09-14 18:43:14 CEST LOG:  database system is shut down
2012-09-14 18:43:17 CEST LOG:  database system was shut down at 2012-09-14 18:43:14 CEST
2012-09-14 18:43:17 CEST LOG:  incomplete startup packet
2012-09-14 18:43:17 CEST LOG:  database system is ready to accept connections
2012-09-14 18:43:17 CEST LOG:  autovacuum launcher started
2012-09-14 18:43:18 CEST LOG:  statement: SELECT d.datname as "Name",
      pg_catalog.pg_get_userbyid(d.datdba) as "Owner",
      pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding",
      d.datcollate as "Collate",
      d.datctype as "Ctype",
      pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges"
FROM pg_catalog.pg_database d
ORDER BY 1;
2012-09-14 18:43:19 CEST LOG:  statement: SELECT d.datname as "Name",
      pg_catalog.pg_get_userbyid(d.datdba) as "Owner",
      pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding",
      d.datcollate as "Collate",
      d.datctype as "Ctype",
      pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges"
FROM pg_catalog.pg_database d
ORDER BY 1;
2012-09-14 18:43:19 CEST LOG:  statement: SELECT d.datname as "Name",
      pg_catalog.pg_get_userbyid(d.datdba) as "Owner",
      pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding",
      d.datcollate as "Collate",
      d.datctype as "Ctype",
      pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges"
FROM pg_catalog.pg_database d
ORDER BY 1;
yt@D620 /home/yt/Sites/yt_tests $ 



--
Yvon


Re: SQLSTATE[08006] [7] server closed the connection unexpectedly

От
"Albe Laurenz"
Дата:
Yvon Thoraval wrote:
>> You may want to set log_statement='all' in postgresql.conf

> i did this change , restart PostgreSQL and test again, with the same error, however postgres log
> didn't report any error, as far as i understand the log :
> 
> 2012-09-14 18:43:14 CEST LOG:  received fast shutdown request
> 2012-09-14 18:43:14 CEST LOG:  aborting any active transactions
> 2012-09-14 18:43:14 CEST LOG:  autovacuum launcher shutting down
> 2012-09-14 18:43:14 CEST LOG:  shutting down
> 2012-09-14 18:43:14 CEST LOG:  database system is shut down
> 2012-09-14 18:43:17 CEST LOG:  database system was shut down at 2012-09-14 18:43:14 CEST
> 2012-09-14 18:43:17 CEST LOG:  incomplete startup packet
> 2012-09-14 18:43:17 CEST LOG:  database system is ready to accept connections
> 2012-09-14 18:43:17 CEST LOG:  autovacuum launcher started

Well, "received fast shutdown request" would explain what is
going on.  The server shuts down, and all active connections
are terminated, which on the client end looks exactly like
you described.

What is odd is that you say it is repeatable.
What could be sending SIGINT to the postmaster whenever
you try to connect?  Are database server and web server
on the same machine?
Try to find out what is going on there.
How does the log look when you enable
log_connections and log_disconnections in postgresql.conf?

Yours,
Laurenz Albe

Re: SQLSTATE[08006] [7] server closed the connection unexpectedly

От
Yvon Thoraval
Дата:


2012/9/17 Albe Laurenz <laurenz.albe@wien.gv.at>
Yvon Thoraval wrote:
>> You may want to set log_statement='all' in postgresql.conf

> i did this change , restart PostgreSQL and test again, with the same error, however postgres log
> didn't report any error, as far as i understand the log :
>
 
<snip />

Well, "received fast shutdown request" would explain what is
going on.  The server shuts down, and all active connections
are terminated, which on the client end looks exactly like
you described.

NO, no it's me having asked for a server restart...
 
What is odd is that you say it is repeatable.
What could be sending SIGINT to the postmaster whenever
you try to connect?  Are database server and web server
on the same machine?
Try to find out what is going on there.
How does the log look when you enable
log_connections and log_disconnections in postgresql.conf?

Yours,
Laurenz Albe


I found something wrong in my setup, i do have - TWO - psql binaries...
The one in my PATH is working well (/usr/bin/psql) and another one (I don't remember it's path) which doesn't work and i suspect this is this one linked to php...
For that reason I've opened another post named "On Ubuntu 12.04 i do have two psql one of those isn't working".
Then, i think this as nothing to do with PostgreSQL but rather with Xubuntu 12.04 LTS...

--
Yvon