Re: Child program using parent program's transaction?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Wayne Conrad <wconrad(at)yagni(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Child program using parent program's transaction?
Date: 2006-09-11 10:00:18
Message-ID: 20060911100018.GA16564@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-09-11 10:03:36 Re: [GENERAL] Problem with lo_export() and lo_import() from remote machine.
Previous Message Alban Hertroys 2006-09-11 09:58:56 Plan for outer joins