Re: Problem with async notifications of table updates - Mailing list pgsql-general

From Tyler, Mark
Subject Re: Problem with async notifications of table updates
Date
Msg-id CADA64FC899992449361EADA6D3EF8B3013217B5@ednex512.dsto.defence.gov.au
Whole thread Raw
In response to Re: Problem with async notifications of table updates  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Problem with async notifications of table updates  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Problem with async notifications of table updates  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Re: Problem with async notifications of table updates  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Re: Problem with async notifications of table updates  (Vivek Khera <vivek@khera.org>)
List pgsql-general
Tom Lane wrote:
>"Tyler, Mark" <Mark.Tyler@dsto.defence.gov.au> writes:
>> What I want to do is to guarantee that the row is available for
>> selection prior to sending the message.
>
> You cannot do that with an AFTER trigger, because whatever it
> does necessarily happens before your transaction commits.

I somehow suspected that this was the answer. It would be nice to have
some sort of FINALLY style of clause for the trigger which was able to
be initiated after the transaction was committed. Of course there would
be very large restrictions on what sort of things could be done in such
a clause.

Clearly NOTIFY itself works around this very problem. I have not looked
at the code but I suspect the NOTIFY command sets a flag that tells the
server to fire the notification as soon as the transaction commits -
thus the command can be inside the trigger context but have an effect
after the trigger completes.

> I suggest rethinking your dislike of NOTIFY.

I have thought very hard about using NOTIFY for this but it has two
large problems (from my point of view). The first is that it forces me
to put far more smarts and state into the subscriber applications. This
is because I cannot pass any information with the NOTIFY apart from the
fact that "something happened". Due to this restriction my subscriber
apps would have to go and look up some secondary table to get sufficient
information to construct the real query. That is just plain ugly in my
view.

Secondly, the lack of any delivery guarantee means my subscriber
applications may miss event notifications. This is a very bad thing for
my particular application.


Mark

IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of
section70 of the CRIMES ACT 1914.  If you have received this email in error, you are requested to contact the sender
anddelete the email. 



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problem with async notifications of table updates
Next
From: Tom Lane
Date:
Subject: Re: Problem with async notifications of table updates