pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Murphy <joe.murphy@aersoft.ie>
To: pgsql-interfaces@postgresql.org <pgsql-interfaces@postgresql.org>
Subject: Re: libpq, threads and connection reset
Date: Thu, 05 Sep 2002 13:54:59 +0100
Message-ID: <3D775423.78A43764@aersoft.com> (raw)
References: <20020828025202.C74E81D1943C8@bjapp2.163.net>
	<3D7751B5.CE431206@aersoft.com>

Sorry, a typo in my previous message see below....

Joe Murphy wrote:

> I'm having some problems with a multi-threaded application using libpq:
>
> Some details:
> OS: Solaris 2.6
> Postgres version 7.2.1
>
> When my application starts up the main thread (1) connects using
> PQsetdbLogin() which is successful
> Another thread (5 for example) issues queries over this connection.
>
> My test is stopping postgres (KILL -INT) and testing if my application
> detects the backend failure and
> tries to re-connect.
>
> Thread 5 issues a PQexec and discovers the error upon which thread 5
> tries to reconnect (after calling PQfinish)
> This reconnection HANGS, here is a stack trace:
>
>      ee037438 poll     (ed906e48, 1, ffffffff)
>      ee04cc74 select   (ed906e50, ed908ea8, ed908f28, ed908eac,
> ed908f2c, 4) + 280
>      ee69e010 pqWait   (0, 1, 485e8, 1, 81010100, ee0882cc) + 1d8
>      ee695178 connectDBComplete (485e8, 0, ee0a3180, 0, efffebc0,
> ee086858) + f8
>      ee69484c PQsetdbLogin (45e28, ed9091a2, 0, 0, 45d68, 45e40) + 558
>
> All access using the connection is serialized using a mutex.
>
> I've tried the same test but with everything running in thread 1 and it
> works OK.
>
> I've managed to spot some differences between the two tests:
>
> Multi Threaded test:

This should read "Single Threaded Test"

>
> The re-connect underlying call to connect returns -1 and sets errno to
> 146 (connection refused)
>
> Single Threaded test:

This should read Multi Threaded test

>
> The re-connect underlying call to connect returns -1 and errno = 0, so
> it thinks the connection is "in progress" and tries
> to complete the connection - but hangs on the select (poll)
>
> Any help or ideas greatly appreciated,
>
> Joe
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        Joe Murphy - AerSoft Limited
             2 Northumberland Avenue, Dun Laoghaire, Co. Dublin.
  phone: +353-1-2301166     direct: +353-1-2145953     fax: +353-1-2301167
  mailto:joe@aersoft.com   mobile: +353-86-8526181  http://www.aersoft.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






view thread (5+ messages)  latest in thread

Message-ID: <3D775423.78A43764@aersoft.com>
Permalink:  ../3D775423.78A43764@aersoft.com/
Also on:    postgresql.org/message-id/3D775423.78A43764@aersoft.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: joe.murphy@aersoft.ie
  Subject: Re: libpq, threads and connection reset
  In-Reply-To: <3D775423.78A43764@aersoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox