pgsql server reset the connection immediately after connected

Started by Dongkuo Maover 13 years ago9 messagesgeneral
Jump to latest
#1Dongkuo Ma
luc.mdk@gmail.com

Hi
Sorry for my English.
I'm running pgsql8.4 server on debian,the client is the python
library(psycopg2) on the same mechine.
The client connect server via 127.0.0.1:5432.

The psycopg2 connect function *succesed,but throw a exception *

server closed the connection unexpectedly

This probably means the server terminated abnormally before or while
processing the request.
*
*

#2Dongkuo Ma
luc.mdk@gmail.com
In reply to: Dongkuo Ma (#1)
Re: pgsql server reset the connection immediately after connected

Sorry!
I typed the enter key and sent the uncomplete message.

The psycopg2 connect function succesed,but throw a exception

server closed the connection unexpectedly
This probably means the server terminated abnormally before or while
processing the request.

when executing any sql statement.

Using tcpdump, I found the server reset the connection immediately after
connected, and i cann't find any log about this.
This is the tcpdump log http://pastebin.com/uW0at4Zd

On Fri, Nov 2, 2012 at 10:24 AM, Dongkuo Ma <luc.mdk@gmail.com> wrote:

Show quoted text

Hi
Sorry for my English.
I'm running pgsql8.4 server on debian,the client is the python
library(psycopg2) on the same mechine.
The client connect server via 127.0.0.1:5432.

The psycopg2 connect function *succesed,but throw a exception *

server closed the connection unexpectedly

This probably means the server terminated abnormally before or while
processing the request.
*
*

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Dongkuo Ma (#1)
Re: pgsql server reset the connection immediately after connected

On 11/01/2012 07:24 PM, Dongkuo Ma wrote:

Hi
Sorry for my English.
I'm running pgsql8.4 server on debian,the client is the python
library(psycopg2) on the same mechine.
The client connect server via 127.0.0.1:5432 <http://127.0.0.1:5432&gt;.

The psycopg2 connect function /succesed,but throw a exception /

server closed the connection unexpectedly

This probably means the server terminated abnormally before or while
processing the request.

Not sure how the connect function could succeed and throw an exception
at the same time?
Some more explanation may be needed.

What does the Postgres log show?

/
/

--
Adrian Klaver
adrian.klaver@gmail.com

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Dongkuo Ma (#2)
Re: pgsql server reset the connection immediately after connected

On 11/01/2012 07:32 PM, Dongkuo Ma wrote:

Sorry!
I typed the enter key and sent the uncomplete message.

The psycopg2 connect function succesed,but throw a exception

server closed the connection unexpectedly
This probably means the server terminated abnormally before or while
processing the request.

when executing any sql statement.

What is the Python code being used?

Using tcpdump, I found the server reset the connection immediately
after connected, and i cann't find any log about this.

Should be in /var/log/postgresql

This is the tcpdump log http://pastebin.com/uW0at4Zd

--
Adrian Klaver
adrian.klaver@gmail.com

#5Dongkuo Ma
luc.mdk@gmail.com
In reply to: Adrian Klaver (#4)
Re: pgsql server reset the connection immediately after connected

Hi
the python code is

logging.info("database connecting...")
conn = connect(database="dbname", user="user",
password="password",host="127.0.0.1")
logging.info("database connected")
conn.autocommit = True
conn.set_client_encoding('UTF8')
cur = conn.cursor()
#the above code executed without exception
#and [server closed the connection unexpectedly] thrown when any
cur.execute() called
I think it's strange because the server reset connection after
connected,and the connect function should throw a exception.

It's nothing in the log file.

Thanks.

On Fri, Nov 2, 2012 at 10:42 AM, Adrian Klaver <adrian.klaver@gmail.com>wrote:

Show quoted text

On 11/01/2012 07:32 PM, Dongkuo Ma wrote:

Sorry!
I typed the enter key and sent the uncomplete message.

The psycopg2 connect function succesed,but throw a exception

server closed the connection unexpectedly
This probably means the server terminated abnormally before or while
processing the request.

when executing any sql statement.

What is the Python code being used?

Using tcpdump, I found the server reset the connection immediately
after connected, and i cann't find any log about this.

Should be in /var/log/postgresql

This is the tcpdump log http://pastebin.com/uW0at4Zd

--
Adrian Klaver
adrian.klaver@gmail.com

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Dongkuo Ma (#5)
Re: pgsql server reset the connection immediately after connected

On 11/01/2012 07:57 PM, Dongkuo Ma wrote:

Hi
the python code is

logging.info <http://logging.info&gt;(&quot;database connecting...")
conn = connect(database="dbname", user="user",
password="password",host="127.0.0.1")
logging.info <http://logging.info&gt;(&quot;database connected")
conn.autocommit = True
conn.set_client_encoding('UTF8')
cur = conn.cursor()
#the above code executed without exception
#and [server closed the connection unexpectedly] thrown when any
cur.execute() called
I think it's strange because the server reset connection after
connected,and the connect function should throw a exception.

You sure you are not doing anything contrary to the instructions here:

http://initd.org/psycopg/docs/usage.html#thread-safety

It's nothing in the log file.

Thanks.

--
Adrian Klaver
adrian.klaver@gmail.com

#7Chris Angelico
rosuav@gmail.com
In reply to: Dongkuo Ma (#5)
Re: pgsql server reset the connection immediately after connected

On Fri, Nov 2, 2012 at 1:57 PM, Dongkuo Ma <luc.mdk@gmail.com> wrote:

Hi
the python code is

logging.info("database connecting...")
conn = connect(database="dbname", user="user",
password="password",host="127.0.0.1")
logging.info("database connected")
conn.autocommit = True
conn.set_client_encoding('UTF8')
cur = conn.cursor()
#the above code executed without exception
#and [server closed the connection unexpectedly] thrown when any
cur.execute() called
I think it's strange because the server reset connection after connected,and
the connect function should throw a exception.

It's nothing in the log file.

Is there a long delay between connecting and executing a query? It may
be that something disconnected you during that time. Or could the
server have been restarted?

Can you make a simple Python script that always fails in this way?

Chris Angelico

#8Dongkuo Ma
luc.mdk@gmail.com
In reply to: Adrian Klaver (#6)
Re: pgsql server reset the connection immediately after connected

I connect to database and then fork a new process!
Now it's ok.
Thanks.

On Fri, Nov 2, 2012 at 11:17 AM, Adrian Klaver <adrian.klaver@gmail.com>wrote:

Show quoted text

On 11/01/2012 07:57 PM, Dongkuo Ma wrote:

Hi
the python code is

logging.info <http://logging.info&gt;(&quot;**database connecting...")

conn = connect(database="dbname", user="user",
password="password",host="127.**0.0.1")
logging.info <http://logging.info&gt;(&quot;**database connected")

conn.autocommit = True
conn.set_client_encoding('**UTF8')
cur = conn.cursor()
#the above code executed without exception
#and [server closed the connection unexpectedly] thrown when any
cur.execute() called
I think it's strange because the server reset connection after
connected,and the connect function should throw a exception.

You sure you are not doing anything contrary to the instructions here:

http://initd.org/psycopg/docs/**usage.html#thread-safety&lt;http://initd.org/psycopg/docs/usage.html#thread-safety&gt;

It's nothing in the log file.

Thanks.

--

Adrian Klaver
adrian.klaver@gmail.com

#9Chris Angelico
rosuav@gmail.com
In reply to: Dongkuo Ma (#8)
Re: pgsql server reset the connection immediately after connected

On Fri, Nov 2, 2012 at 2:43 PM, Dongkuo Ma <luc.mdk@gmail.com> wrote:

I connect to database and then fork a new process!
Now it's ok.
Thanks.

Ah, yes, that would be a dangerous thing to do :)

ChrisA