[OSM-dev] foreign key constraint violation in live-api

Tom Hughes tom at compton.nu
Tue May 4 12:59:32 BST 2010

On 04/05/10 12:36, IgnacioZ wrote:

>   They were done in a for loop and before I start the next request, I
> receive the answer, though by looking at my code it could happen that
> two requests are done in parallel, after receiving the Id of the
> previous one, I continue and the previous connection may not have been
> finalized (they are different instances).
> Do you think that could be the reason ?

Once you get the ID back everything should be complete on the server so 
if you were waiting that long there shouldn't be a problem. That isn't 
what I'm seeing in the server logs though.

I have the request to add 717587768 starting:

[2010-05-02 19:02:06.985698 #9411] Processing NodeController#create (for 
...) [PUT]

then the request add 717587767 starting:

[2010-05-02 19:02:06.998618 #9413] Processing NodeController#create (for 
...) [PUT]

then they both deadlocked (probably against each other):

[2010-05-02 19:02:08.136362 #9413] Deadlock detected on retry 1, 
restarting transaction
[2010-05-02 19:02:08.282322 #9411] Deadlock detected on retry 1, 
restarting transaction

after which they both report FK violations.

Now there is presumably a bug in the way we restart the deadlocked 
transaction that leads to the FK violations but I suspect it was the 
parallel upload that led to the deadlock and that it explains why other 
people don't see the same problems.


Tom Hughes (tom at compton.nu)

More information about the dev mailing list