Re: [INTERFACES] libpq and multi-threading on Linux?

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Michael Olivier <molivier(at)yahoo(dot)com>
Cc: pgsql interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: [INTERFACES] libpq and multi-threading on Linux?
Date: 1999-02-13 12:37:32
Message-ID: Pine.LNX.4.04.9902131232260.29227-100000@maidast.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Wed, 10 Feb 1999, Michael Olivier wrote:

> Hi folks,
>
> I apologize in advance if I have overlooked docs, but I haven't been
> able to find a discussion of how PostGreSQL via libpq on Linux fares
> with pthreads. Can someone point me to docs if available, or otherwise
> enlighten me? How well does it work and what are the important design
> issues to consider?
>
> I'm expecting to create a pool of db connections to use within a
> long-running process, which will create a new thread for each incoming
> request from a client. I've found just a very little bit about PG
> being multi-processing, but not how it will interact with a
> multi-threaded client. I appreciate your comments.

Take a look on how I got the JDBC driver to handle multi-threading.

At certain points, the driver obtains a lock on the network connection
before sending a query, and releases the lock when the query has finished
(ie: all results have been returned in to the ResultSet).

Another place where this locking occurs is in FastPath, a lock is obtained
on the network connection before sending the function call, and released
when the call returns.

When another thread tries to run a query, it has to wait until the lock is
released, then it can use that network connection. Also, it allows calls
to LargeObjects to run in one thread without any worries of confusing the
backend while queries are running.

I'm not sure if this is what you were after.

Peter

--
Peter T Mount peter(at)retep(dot)org(dot)uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Aaron Dunlop 1999-02-13 19:23:09 Perl5 interface under win32
Previous Message Michael Meskes 1999-02-13 11:39:17 Re: [INTERFACES] facing problem with ecpg