opened connection - Mailing list pgsql-general

From Levente Kovacs
Subject opened connection
Date
Msg-id 20120930185435.2762c7f7@jive.levalinux.org
Whole thread Raw
Responses Re: opened connection  (Nathan Wagner <nw@hydaspes.if.org>)
Re: opened connection  (Darren Duncan <darren@darrenduncan.net>)
List pgsql-general
Dear List,


I've been using PostgreSQL for quite while, but I'd need some direction on
how to handle an opened socket to the database in longer periods.

I open the connection to my database with PQconnectdb().

I access the database, everything is fine. However, if I don't access the
database for a long time (measured in days), the connection is broken. I
get this error message:

SQL action failed: 'FATAL:  terminating connection due to administrator
command SSL connection has been closed unexpectedly.

I tried to check the connection by PQstatus() before calling PQexec(), but
this doesn't detect the broken connection.

How can I detect this problem?

Is it wise to terminate the connection each time the PQexec() finished?
Should I keep the connection for say 1hour, then terminate it?
Is there a common practice?

Any guides are welcome.

Thank you,
Levente

--
Levente Kovacs
CTO, CSO
http://levente.logonex.eu


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: transitive pruning optimization on the right side of a join for partition tables
Next
From: Jeff Janes
Date:
Subject: Re: Would my postgresql 8.4.12 profit from doubling RAM?