opened connection

From: Levente Kovacs <leventelist(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: opened connection
Date: 2012-09-30 16:54:35
Message-ID: 20120930185435.2762c7f7@jive.levalinux.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nathan Wagner 2012-09-30 23:41:14 Re: opened connection
Previous Message Tom Lane 2012-09-30 15:14:31 Re: transitive pruning optimization on the right side of a join for partition tables