[OSM-dev] Data checks?

Martijn van Oosterhout kleptog at gmail.com
Mon Feb 18 16:35:06 GMT 2008


On Feb 18, 2008 9:42 AM, Tom Hughes <tom at compton.nu> wrote:
> That still has race conditions unless you can do the check in an
> atomic fashion, which I'm not sure you can.

It can work: For inserting/updating ways you're checking the nodes
exist already, add a FOR SHARE to each query
This stops someone else deleting them in the meantime. And a FOR
UPDATE on the way against concurrent updates. For deleting a node, in
the initial existance check add a FOR UPDATE to the query. Now check
the ways/relations (nothing special needed here). Finally delete the
node.

It's poor man's referential integrity, but it's what Real Databases do
in the background when doing referential integrity.

> Well obviously we could just lock everything, but the users of
> the API probably wouldn't like the result much.

AFAICS it doesn't require any additional queries so the performance
effect should be marginal. But it probably only works for innodb
tables :(

Have a nice day,
-- 
Martijn van Oosterhout <kleptog at gmail.com> http://svana.org/kleptog/




More information about the dev mailing list