Re: multiple threads using one connection - Mailing list pgsql-interfaces

From Bruce Momjian
Subject Re: multiple threads using one connection
Date
Msg-id 200602281817.k1SIH7l10966@candle.pha.pa.us
Whole thread Raw
In response to Re: multiple threads using one connection  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: multiple threads using one connection
List pgsql-interfaces
Alvaro Herrera wrote:
> Robert Gruszka wrote:
> > Hi,
> > 
> > I have multi-thread application written in Ada which uses APQ. All 
> > threads use the same connection (can't afford one connection per 
> > thread). I compiled libpq with --enable-thread-safty option.
> > When two threads try to execute a query at the same time one of them is 
> > blocked and even when the other one finishes it is not unblocked.
> 
> The libpq API is not really intended to be used by multiple threads
> simultaneously (unless you make sure only one thread is submitting a
> query and waiting for the result at any time).
> 
> The --enable-thread-safety flag is merely to ensure that the calls to
> other libraries (Kerberos, etc) are handled in a thread-safe manner.  It
> doesn't have any effect on the thread safety of the libpq API itself.

Just to clarify, libpq is thread-safe is each thread uses its own
connection object.

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-interfaces by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: multiple threads using one connection
Next
From: Eugene Prokopiev
Date:
Subject: Python psycopg transaction isolation level