Skip site navigation (1) Skip section navigation (2)

Re: multiple threads using one connection

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Gruszka <rgruszka(at)power(dot)com(dot)pl>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: multiple threads using one connection
Date: 2006-02-28 18:17:07
Message-ID: (view raw or whole thread)
Lists: 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
  SRA OSS, Inc.

  + If your life is a hard drive, Christ can be your backup. +

In response to


pgsql-interfaces by date

Next:From: Eugene ProkopievDate: 2006-02-28 18:27:29
Subject: Python psycopg transaction isolation level
Previous:From: Alvaro HerreraDate: 2006-02-28 15:09:50
Subject: Re: multiple threads using one connection

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group