Repository navigation
Closed
Description
From: https://developmentseed.slack.com/archives/CACTQ7MU4/p1715276861543709

We're experiencing timeout errors (proxy_fcgi:error) with our Apache and cgimap setup when uploading large datasets to our OHM-api web. During large data uploads, the server frequently logs proxy_fcgi:error indicating that the timeout specified has expired. This error seems to occur mainly when the load on the server is high.
App 8444 output: WARN: advpng none at /usr/bin/advpng (== none) is of unknown version
[ N 2024-05-10 15:41:05.8218 349/T3 age/Cor/CoreMain.cpp:1146 ]: Checking whether to disconnect long-running connections for process 8536, application /var/www (production)
App 9778 output: WARN: advpng none at /usr/bin/advpng (== none) is of unknown version
[Fri May 10 15:46:07.882219 2024] [proxy_fcgi:error] [pid 360:tid 140526506424000] (70007)The timeout specified has expired: [client 10.10.47.154:38824] AH01075: Error dispatching request to : (polling)
[Fri May 10 15:47:19.762287 2024] [proxy_fcgi:error] [pid 359:tid 140526422505152] (70007)The timeout specified has expired: [client 10.10.47.154:43766] AH01075: Error dispatching request to : (polling)
[Fri May 10 15:48:31.410450 2024] [proxy_fcgi:error] [pid 360:tid 140526600832704] (70007)The timeout specified has expired: [client 10.10.47.154:56726] AH01075: Error dispatching request to : (polling)
[Fri May 10 15:49:43.226386 2024] [proxy_fcgi:error] [pid 359:tid 140526453974720] (70007)The timeout specified has expired: [client 10.10.47.154:49158] AH01075: Error dispatching request to : (polling)
[Fri May 10 15:50:54.714215 2024] [proxy_fcgi:error] [pid 360:tid 140526516913856] (70007)The timeout specified has expired: [client 10.10.47.154:56044] AH01075: Error dispatching request to : (polling)
[Fri May 10 15:52:06.750295 2024] [proxy_fcgi:error] [pid 359:tid 140526537893568] (70007)The timeout specified has expired: [client 10.10.47.154:45536] AH01075: Error dispatching request to : (polling)
App 11208 output: WARN: advpng none at /usr/bin/advpng (== none) is of unknown version
[ W 2024-05-10 16:36:17.4959 349/Tb age/Cor/Con/CheckoutSession.cpp:265 ]: [Client 2-29834] Returning HTTP 503 due to: Request queue full (configured max. size: 100)
[ W 2024-05-10 16:37:41.8413 349/T7 age/Cor/Con/CheckoutSession.cpp:265 ]: [Client 1-29835] Returning HTTP 503 due to: Request queue full (configured max. size: 100)
[ W 2024-05-10 16:38:02.0024 349/Tb age/Cor/Con/CheckoutSession.cpp:265 ]: [Client 2-29835] Returning HTTP 503 due to: Request queue full (configured max. size: 100)
[ W 2024-05-10 16:38:06.3191 349/T7 age/Cor/Con/CheckoutSession.cpp:265 ]: [Client 1-29836] Returning HTTP 503 due to: Request queue full (configured max. size: 100)
[ W 2024-05-10 16:38:42.0237 349/Tb age/Cor/Con/CheckoutSession.cpp:265 ]: [Client 2-29836] Returning HTTP 503 due to: Request queue full (configured max. size: 100)
Full log in /var/log/apache2/error.log: https://gist.github.com/Rub21/87fd55f82a5c83756cc81fd6385c8daf
Reacted by Jeff Meyer
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsIn Production
Activity
jeffreyameyer commentedon May 12, 2024
Is fixing this as simple as adjusting the timeout duration or is there an underlying other problem?
Rub21 commentedon May 13, 2024
Not really, I have already tested increasing the timeout, but it did not work. I'm still trying to find out where exactly the error is.
@batpad, do you have any hunch about this issue?
Rub21 commentedon May 14, 2024
I've been running many tests, uploading large quantities of objects to the API. When there's a large amount of data to process, a 504 error from the API appears, specifically from CGIMAP. Here JOSM's logs https://gist.github.com/Rub21/1bb46bb004f89fdda787fc96b896f2a3
When the web API and the database are started, everything works well, and the API supports a large amount of data. However, as more data is gradually added, it starts to throw 504 errors, I checked the database, and it seems that the bottleneck is in the number of connections to the database, as there are more and more data to upload the cgimap start trowing the error
I have increased the number of connection once more:
Rub21 commentedon May 14, 2024
The issues is still persisting, currently we are using cgimap version about 10 months ago https://github.com/zerebubuth/openstreetmap-cgimap/tree/5cd3d21bebe9d205828608be4c65bbda8b464308, after that there were a lot changes, I am going to update the version of cgimap, and see how it goes.
mmd-osm commentedon May 14, 2024
So what’s inside CGImap log files?
Rub21 commentedon May 14, 2024
hey @mmd-osm , Thanks for taking a look at this issue. Here are the cgimap and JOSM logs: https://gist.github.com/Rub21/6b66bac8bc6912d8398677f3bad8f7b2. During the last upload, a timeout error appeared, which led to some incomplete ways or relations and heavy loads. e.g 👇 , However, cgimap does not show any unusual errors.
Same issue in the both version :
I have already added a ProxyTimeout=600, but it is not working because the issue is still there: https://github.com/OpenHistoricalMap/ohm-deploy/blob/cgimap/images/web/config/production.conf#L29.
mmd-osm commentedon May 14, 2024
Thanks for sharing the CGImap log files. From what I can see there, we have some fairly long query times for two queries involving the current_way_nodes table:
Statement:
Statement:
As a result of these long run times, it seems that JOSM is trying to upload to the same changeset another time, while the first upload is still running. This could happen due to the Gateway timeout, in which case JOSM doesn't know if the data has already been successfully uploaded or not.
By the way, if you happen to have less than 10'000 changes to be uploaded, you could try uploading them all at once, instead of using the chunked upload with a chunk size of 2000. This way, the upload would be either complete or fail altogether, rather than some mixed state, where only parts of the changes have been uploaded.
Here's an example involving process ids 305 and 307:
--> starts another upload for the same changeset in another process
You can see a bit further down that the second process tries to lock changeset 118101 again, but needs to wait for process 307 to finish first. Process 307 spends most of the time in the statement "current_way_nodes_to_history".
Maybe you could investigate in more detail, why both statements I mentioned above take so much time. I find this rather unusual.
Rub21 commentedon May 15, 2024
Thank you, @mmd-osm. I will check those queries. Also sometimes, a 409-Conflict error is triggered in the cgimap log when trying to upload the changeset again and again, This occurs when attempting to upload 27k objects.https://staging.openhistoricalmap.org/changeset/118113
mmd-osm commentedon May 15, 2024
You can’t upload more than 10k changes in a single changeset, unless you have increased the default value. JOSM should automatically split 27k changes into 3 changesets.
Rub21 commentedon May 15, 2024
Yes, JOSM split the changeset into three chunks. The first two went okay, but the last one threw a 409 error.
Rub21 commentedon May 22, 2024
For now, I have updated the configuration, increasing the number of object , https://github.com/OpenHistoricalMap/ohm-website/blob/staging/config/settings.yml#L36-L40, part of adding ProxyTimeout
mmd-osm commentedon May 23, 2024
I commented on the ProxyTimeout here as well: OpenHistoricalMap/ohm-website#245 (comment)
From the log above it seems that something is terminating the connection after exactly 60s. I think that's caused by the FastCGI proxy. There are some settings to control the wait time like
FcgidIOTimeout(The FastCGI application must begin generating the response within this period of time. Increase this directive as necessary to handle applications which take a relatively long period of time to respond.). In this scenario, CGImap would only start sending data after all database statements have been processed. If this is taking so much time in your environmnt, FastCGI proxy might terminate the connection too early.Then, like I've mentioend before, it makes sense to look into PostgreSQL response times a bit closer, and do some more tracing / analysis.
62 remaining items
bitner commentedon Jul 16, 2024
@mmd-osm Generally, it is considered bad practice to use Query Hints or settings like
SET enable_mergejoin to off;Using those blunt instruments is definitely a great thing to use when testing, but in production, it is generally a sign that you have bad statistics or memory / planner settings. That being said, there is certainly a time and a place to use these tools, but it should definitely be seen as a last ditch option and not as something that you reach for first.mmd-osm commentedon Jul 16, 2024
Yes, I know. I just wanted to mention that adding some specialized queries like above is not really an option for us, since in OpenStreetMap we will likely have very different data characteristics.
If you don't manage to improve performance on OHM by having appropiate settings in place, I wouldn't have an issue with offering an option for additional db hints. That will in any case be much less of a headache.
bitner commentedon Jul 16, 2024
If you have a large list of ids that you are passing in that are generally well packed, it should not be too difficult to calculate the min and max of that list so that you can add the BETWEEN min AND max clause
mmd-osm commentedon Jul 16, 2024
Right, I would have to do some analysis, if this is frequent enough in OSM. I could imagine that large landuse imports in Norway/Sweden (?) or Canada might have both large amounts of relations as well as a packed id range. I need to check what the runtime of these uploads was like.
For Canada, this would be https://www.openstreetmap.org/user/jmarchon importing from NRCan-CanVec-10.0
In general, the slowest uploads I've seen (somewhere taking about 1.5 mins or so) included a fair amount of FlixBus bus routes. In that case, the large number of relation members was more of an issue, not so much the number of relations in the changeset.
jeffreyameyer commentedon Jul 17, 2024
Crud... just encountered another timeout error
https://www.openhistoricalmap.org/changeset/129940
Rub21 commentedon Jul 17, 2024
Thank you, @mmd-osm and @bitner. Your advices has been very valuable.
I have been evaluating the use of between in the query to filter the IDs. To implement this, we need to update the cgimap code and for large ranges relations' ids , the query still takes a considerable amount of time to complete.
Setting
enable_mergejoin=falseandenable_hashjoin=falsein the database works fine. Even if disabling these settings is not considered best practice, I believe it is the way to go since it is already running on the large OSM database. In our case, I tested it and found that it runs in less time, even when the relations have a large range of IDs. e.gresults:
@batpad I’d like to know your thoughts on this approach?
batpad commentedon Jul 17, 2024
First, just want to give a big thank you to everyone digging into this. @mmd-osm - the OHM project owes you a LOT of beer and I hope we find the opportunity to pay that debt some day :-)
@bitner - thanks so much for identifying the issue with statistics.
Is this something we should setup to run on a regular basis or so?
I would really really like to not have to fork upstream, and since upstream doesn't have any issues with the query, I can see why this might not make sense to get into upstream, even if it does result in an improvement for us.
Without knowing the details of what these settings do or why it's considered bad practice, I would instinctively still advocate for this approach, especially if this is what OSM does. I would much rather do something that may seem suboptimal, but follows what upstream does, rather than fork / make changes that we may not be able to get merged upstream.
I'll do some reading on these settings and @bitner, will probably nice to talk through the implications of doing this, but if setting these options gets us through this without having to re-write SQL queries in CGIMap, I'm 👍 .
There's likely a larger conversation to be had around how we manage the database as it grows. Running postgres in our cluster on AWS may not be either the most efficient or cost effective as the database continues to grow, and it maybe good to start having a conversation looking at options. For now @Rub21 if setting
enable_mergejoin=falseandenable_hashjoin=falsefixes the issue, I would advocate for just doing this.Rub21 commentedon Jul 17, 2024
@batpad @jeffreyameyer I've just set up the values in the production DB,
It should be ok now!
jeffreyameyer commentedon Jul 18, 2024
I've been hitting some problems with relation-related uploads. Is everything still iin good shape on production?
Problems = upload timing out; changeset not closing. Similar to before.
And now, server is under heavy load:

jeffreyameyer commentedon Jul 18, 2024
Now this:

And the website is still down.
Rub21 commentedon Jul 18, 2024
Weird, timeout for ingress is set up for 20 min and 200MB,
And for apache config proxytimeout is set up in 10 min. https://github.com/OpenHistoricalMap/ohm-deploy/blob/main/images/web/config/production.conf#L29 let me me increase more the apache proxy configs..
also seems this new issue should be in another ticket.
Rub21 commentedon Jul 18, 2024
The cgimap query issue has been fixed. Closing this ticket and opening a new ticket to discuss the heavy load on the website: #850