Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Race condition ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 15456 of 15975
Post > Topic >>

Race condition with notifications

by scott_ribe@[EMAIL PROTECTED] (Scott Ribe) May 4, 2008 at 05:55 PM

Table foo has a trigger that on insert raises a notice.

Process A listens for that notice, and blocks on the socket (using
kqueue).

Process B commits an insert of a row into that table, then commits an
insert
of another row immediately.

Process A wakes up and reads the notice, queries table foo for new
records,
finds only the first, processes it, checks the socket and blocks.

In other words, in the second insert transaction, pg seems to be
coalescing
the second notice after the first notice has been delivered, but before
the
second transaction is visible to other processes...

> So it is a bad idea to depend on the number of notifications received.
> Instead, use NOTIFY to wake up applications that need to pay attention
to
> something, and use a database object (such as a sequence) to keep track
of
> what happened or how many times it happened.

Uhm, yeah? 2 changes committed, 1 notice sent, 1 change visible on receipt
of notice.

Of course I can query table foo for new records twice, and that seems to
work, but it also seems like a bad idea to depend on that kind of timing
detail. (FYI, merely inserting a couple of log statements when process B
wakes up results in both changes being seen by the query.)

-- 
Scott Ribe
scott_ribe@[EMAIL PROTECTED]
(303) 722-0567 voice



-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




 4 Posts in Topic:
Race condition with notifications
scott_ribe@[EMAIL PROTECT  2008-05-04 17:55:28 
Re: Race condition with notifications
tgl@[EMAIL PROTECTED] (T  2008-05-04 20:06:43 
Re: Race condition with notifications
scott_ribe@[EMAIL PROTECT  2008-05-04 20:37:30 
Re: Race condition with notifications
tgl@[EMAIL PROTECTED] (T  2008-05-04 22:48:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 9:43:27 CDT 2008.