Re: how to ensure a client waits for a previous transaction to finish?

From: Vick Khera <vivek(at)khera(dot)org>
To: Dan Kortschak <dan(dot)kortschak(at)adelaide(dot)edu(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to ensure a client waits for a previous transaction to finish?
Date: 2009-12-07 21:25:38
Message-ID: 2968dfd60912071325s7864029ewb15c00c6374123fb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Dec 7, 2009 at 4:00 PM, Dan Kortschak
<dan(dot)kortschak(at)adelaide(dot)edu(dot)au> wrote:
> During manual testing everything works, but automating it results in the
> query scripts starting before the population transactions having
> completed, so they give erroneous result.
>

Update your process to have the query scripts wait until the
population scripts are done. Either that or have the populate script
LOCK TABLE the first table that the query is going to use, and it will
automatically block until your transaction is complete for populating.

But really, it sounds like you have a process coordination problem,
not a database problem.

Hmmm.... you could use the DB to synchronize by having the query
program LISTEN for an event and wait until that arrives, then have the
populating program NOTIFY that event once it is done. Just select()
on the Pg socket on the query program and once it is ready to read,
check for any NOTIFY events that may have come.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2009-12-07 21:26:29 Re: how to ensure a client waits for a previous transaction to finish?
Previous Message Dan Kortschak 2009-12-07 21:23:46 Re: how to ensure a client waits for a previous transaction to finish?