Re: Child program using parent program's transaction? - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Child program using parent program's transaction?
Date
Msg-id 20060911100018.GA16564@svana.org
Whole thread Raw
In response to Child program using parent program's transaction?  (Wayne Conrad <wconrad@yagni.com>)
List pgsql-general
On Wed, Sep 06, 2006 at 03:21:04PM -0700, Wayne Conrad wrote:
> I work with a system designed as lots of little cooperating worker
> programs, with boss programs that... well, boss the worker programs
> around.
>
> Boss and workers all use the same database.
<snip>
> Today, it would once again be convenient to have an exec'd program do
> its work in the context of its parent program's transaction.  So,
> before I once again decide that I don't actually want to do that, can
> you tell me... is it possible?  And, would any sane person do it?

The answer is, not really. If you're only fork()ing you can get away
with it as long as you make sure no two processes are accessing the db
at the same time. There's a little too much state to transfer a
connection from one process to another.

What you could do is have a single process that handles the actual
connection to the database and have the other processes talk to it to
do the queries. That way you have complete control over who accesses
what in which connection.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Plan for outer joins
Next
From: Martijn van Oosterhout
Date:
Subject: Re: [ADMIN] Problem with lo_export() and lo_import() from remote machine.