Re: A successful SELECT 1; on failed connection

From: Marko Kreen <markokr(at)gmail(dot)com>
To: Croepha <croepha(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: A successful SELECT 1; on failed connection
Date: 2011-09-30 05:56:50
Message-ID: CACMqXCJ-ctCkbcaUuzUS2WDSvh9v_B1retk4qdSd=ZLs-FzeGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Thu, Sep 29, 2011 at 10:34 PM, Croepha <croepha(at)gmail(dot)com> wrote:
> I am developing a network appliance application that uses psycopg2 to
> connect to a database through an OpenVPN connection. The application has two
> modes that it switches between, an online mode and a disconnected mode.  It
> periodically tries to reconnect once it is in a disconnected mode.  It tests
> the connection by doing a connection.cursor().execute('SELECT 1;').   The
> application log reports coming online and then going back offline,
> but during this time the OpenVPN log reports being offline...
> There may be a bug in my application, but I thought I would ask and see if
> anyone else has seen anything like this?

You would need both connect_timeout and tcp keepalive
for reconnect to be reliable. But otherwise its probably app problem.

--
marko

In response to

Browse psycopg by date

  From Date Subject
Next Message Croepha 2011-10-01 08:18:37 so, is connection.poll() supposed to block?
Previous Message Marko Kreen 2011-09-30 05:54:14 Re: Cursor copy_from with server crash