Re: Summary table trigger example race condition - Mailing list pgsql-patches

From Jim C. Nasby
Subject Re: Summary table trigger example race condition
Date
Msg-id 20060111000951.GQ3902@pervasive.com
Whole thread Raw
In response to Re: Summary table trigger example race condition  (Mark Kirkwood <markir@paradise.net.nz>)
Responses Re: Summary table trigger example race condition
List pgsql-patches
On Sun, Jan 08, 2006 at 04:13:01PM +1300, Mark Kirkwood wrote:
> After re-examining the original code, it looks like it was not actually
> vulnerable to a race condition! (it does the UPDATE, then if not found
> will do an INSERT, and handle unique violation with a repeat of the same
> UPDATE - i.e three DML statements, which are enough to handle the race
> in this case).

What happens if someone deletes the row between the failed insert and
the second update? :)

AFAICT, example 36-1 is the only way to handle this without creating a
race condition.

> However Jim's change handles the race needing only two DML statements in
> a loop, which seems much more elegant! In addition it provides a nice
> example of the 'merge' style code shown in e.g 36-1.

What's SOP here... should I ping someone to let them know this patch
should be committed now that those who care are happy with it?
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: TupleDesc refcounting
Next
From: Mark Kirkwood
Date:
Subject: Re: Summary table trigger example race condition