openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.19k stars 912 forks source link

Error 500 when downloading relations for a way #1354

Closed Zverik closed 7 years ago

Zverik commented 7 years ago

http://api.openstreetmap.org/api/0.6/way/120036484/relations

First time works, but after subsequent calls (Cmd+R, Cmd+R etc) it displays an error.

img_2016-11-01 14 16 04

zerebubuth commented 7 years ago

I wasn't able to reproduce this, but conditions on the server may be different now than they were an hour ago.

Transcribing the error image:

ERROR: prepared statement "a14" already exists,: SELECT "current_relation_members".* FROM "current_relation_members" WHERE "current_relation_members"."member_type" = $1 AND "current_relation_members"."member_id" = $2

Looks from this Rails issue like the problem might be that the database connection is not cleaned up properly after hitting a timeout?

Zverik commented 7 years ago

I reproduce this bug easily: by clicking on the link above, and then refreshing the page. Error message:

ActiveRecord::StatementInvalid: PG::DuplicatePstatement: ERROR: prepared statement "a4" already exists : SELECT "current_relation_members".* FROM "current_relation_members" WHERE "current_relation_members"."member_type" = $1 AND "current_relation_members"."member_id" = $2

zerebubuth commented 7 years ago

I didn't say that the bug could not be reproduced, nor that you weren't able to reproduce it - only that I wasn't able to reproduce it.

I've tried again today, and I'm still not able to reproduce it. Previously, I was using curl, but I've now tried with my browser but neither tool has been able to reproduce it. I don't doubt that you are able to reproduce it, though.

Did you hit a timeout the first time the page loads, or did it load okay?

Zverik commented 7 years ago

It's okay, I don't doubt it is hard to reproduce this issue. For the first time the page did load okay, but it took a very long time, near half a minute or more.

mboeringa commented 7 years ago

It's okay, I don't doubt it is hard to reproduce this issue. For the first time the page did load okay, but it took a very long time, near half a minute or more.

Just for the record, I ran into similar http 500 issues today with some relations while accessed from overpass turbo via the links displayed in the result window. The behaviour seems inconsistent, sometimes it fails, sometimes it doesn't. I did notice the significant lag in showing the relation too.

E.g. when I try opening this URL which points to the relation of the Canary Islands archipelago, I initially got a consistent 500 error: https://www.openstreetmap.org/relation/5392189

However, now I am able to open it, but it is slow. Of course, this is not entirely unsurprising given the size of the objects involved in the relation and the number of them, so it may just be a time-out thing...

pnorman commented 7 years ago

E.g. when I try opening this URL which points to the relation of the Canary Islands archipelago, I initially got a consistent 500 error:

Are you getting the same error message about a prepared statement?

mboeringa commented 7 years ago

@pnorman , this was following a link from the overpass turbo result page showing the map result in the right pane of the tool. It normally simply opens up the OpenStreetMap website with the relation selected, as you can see from the link. However, this time, instead of opening up the page, I got an OpenStreetMap website error page with logo and a statement about "contacting the OpenStreetMap community" about this http 500 error.

As said, the first few times I tried it failed, but now I can open it and see the relation result on the OpenStreetMap website.

pnorman commented 7 years ago

@pnorman , this was following a link from the overpass turbo result page showing the map result in the right pane of the tool. It normally simply opens up the OpenStreetMap website with the relation selected, as you can see from the link. However, this time, instead of opening up the page, I got an OpenStreetMap website error page with logo and a statement about "contacting the OpenStreetMap community" about this http 500 error.

As said, the first few times I tried it failed, but now I can open it and see the relation result on the OpenStreetMap website.

Probably unrelated to this issue then.

zerebubuth commented 7 years ago

Has anyone seen this error since #1381 was merged (2nd Dec 2016)?

I'm trying to figure out if that might have been the same error, but I didn't explicitly link in this ticked from the PR at the time. And now I've forgotten whether they were related...

mboeringa commented 7 years ago

@zerebubuth , I haven't used the OpenStreetMap website's options for showing relations and other map data enough lately to say something definitive.

However, when I just tried to open the Canary Island's relation that I linked in one of the previous posts, I had no trouble doing so in both Firefox and Edge browser. The relations opened fine in both browsers (albeit a bit sluggish, but that is unsurprising giving the data).

EDIT: This may be totally unrelated, but for what its worth, I used to have regular time outs when downloading data from the german XAPI server using ArcGIS if I attempted to download larger sections (e.g. >= 100-250 MB *.osm XML files). Actually, the file would be written, but contained a message regarding a time-out at the end of the file when inspected in Visual Studio, and some downloaded relations were hence incomplete. This made the files unusable. I have the vague feeling this has ameliorated and happens less often.

Zverik commented 7 years ago

I don't get that error on the link from the opening message. Maybe I'm not patient enough: it takes several minutes to get the result.

pnorman commented 7 years ago

This may be totally unrelated, but for what its worth, I used to have regular time outs when downloading data from the german XAPI server

Yes, it's unrelated since you are talking about a different server running different software operated by different people giving a different error. This issue is about an error which mentions prepared statements, not a general timeout

The way to show this is fixed is to get an earlier version of the code, trigger the error (probably by forcing a timeout somehow), and then that the new version doesn't trigger that. I don't see that happening and don't think it's worth the effort. I recommend closing as some combination of fixed and cannot reproduce anymore, and it can be reopened if prepared statement errors reoccur.