Skip to content

Errors with Proxy_fcgi and CGImap When Uploading Large Data Sets #783

Closed

Description

@Rub21

From: https://developmentseed.slack.com/archives/CACTQ7MU4/p1715276861543709
image

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

cc. @jeffreyameyer @1ec5 @batpad @danrademacher

Activity

  1. jeffreyameyer commented on May 12, 2024

    @jeffreyameyer
    Member

    Is fixing this as simple as adjusting the timeout duration or is there an underlying other problem?

  2. Rub21 commented on May 13, 2024

    @Rub21
    MemberAuthor

    Is fixing this as simple as adjusting the timeout duration or is there an underlying other problem?

    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?

  3. Rub21 commented on May 14, 2024

    @Rub21
    MemberAuthor

    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

    2024-05-13 10:56:50.809 INFO: Gateway Time-out
    2024-05-13 10:56:50.809 INFO: Waiting 10 seconds ...
    2024-05-13 10:57:00.852 INFO: OK - trying again.
    2024-05-13 10:57:00.852 INFO: Starting retry 2 of 5.
    2024-05-13 10:57:00.871 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118027/upload (335 kB) ...
    2024-05-13 10:58:01.985 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118027/upload -> HTTP/1.1 504 (1 min 0 s; 160 B)
    2024-05-13 10:58:02.003 INFO: Gateway Time-out
    2024-05-13 10:58:02.003 INFO: Waiting 10 seconds ...
    

    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:

    • Staging : 200
    • Production: 500
  4. Rub21 commented on May 14, 2024

    @Rub21
    MemberAuthor

    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.

  5. mmd-osm commented on May 14, 2024

    @mmd-osm

    So what’s inside CGImap log files?

  6. Rub21 commented on May 14, 2024

    @Rub21
    MemberAuthor

    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.

    • JOSM logs
    2024-05-14 15:08:11.097 INFO: PUT https://staging.openhistoricalmap.org/api/0.6/changeset/create (219 B) ...
    2024-05-14 15:08:11.903 INFO: PUT https://staging.openhistoricalmap.org/api/0.6/changeset/create -> HTTP/1.1 200 (572 ms; 6 B)
    2024-05-14 15:08:11.903 INFO: OK
    2024-05-14 15:08:12.029 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118102/upload (900 kB) ...
    2024-05-14 15:09:13.172 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118102/upload -> HTTP/1.1 504 (1 min 0 s; 160 B)
    2024-05-14 15:09:13.177 INFO: Gateway Time-out
    2024-05-14 15:09:13.178 INFO: Waiting 10 seconds ...
    2024-05-14 15:09:23.231 INFO: OK - trying again.
    2024-05-14 15:09:23.231 INFO: Starting retry 1 of 5.
    2024-05-14 15:09:23.257 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118102/upload (900 kB) ...
    2024-05-14 15:10:24.669 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118102/upload -> HTTP/1.1 504 (1 min 0 s; 160 B)
    2024-05-14 15:10:24.681 INFO: Gateway Time-out
    2024-05-14 15:10:24.682 INFO: Waiting 10 seconds ...
    2024-05-14 15:10:34.737 INFO: OK - trying again.
    2024-05-14 15:10:34.737 INFO: Starting retry 2 of 5.
    
    
    image

    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.

  7. mmd-osm commented on May 14, 2024

    @mmd-osm

    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:

    [2024-05-14T19:56:28 #311] Started request for map(-77.2450447,-12.1438929,-77.1885681,-12.0937100) from 10.10.47.154
    [2024-05-14T19:57:34 #311] Executed prepared statement nodes_from_ways in 65350 ms, returning 1601 rows, 1601 affected rows
    

    Statement:

       SELECT DISTINCT wn.node_id AS id FROM current_way_nodes wn WHERE wn.way_id = ANY($1)
    [2024-05-14T20:06:11 #307] Executed prepared statement current_way_nodes_to_history in 55163 ms, returning 0 rows, 18652 affected rows
    
    [2024-05-14T20:07:34 #305] Executed prepared statement current_way_nodes_to_history in 45074 ms, returning 0 rows, 18652 affected rows
    

    Statement:

       INSERT INTO way_nodes (way_id, node_id, version, sequence_id)
           SELECT  way_id, node_id, version, sequence_id 
           FROM current_way_nodes wn
           INNER JOIN current_ways w
           ON wn.way_id = w.id
           WHERE id = ANY($1) )

    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:

    [2024-05-14T20:05:15 #307] Started request for changeset/upload 118101 from 10.10.47.154
    [2024-05-14T20:06:27 #305] Started request for changeset/upload 118101 from 10.10.47.154
    

    --> 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".

    [2024-05-14T20:06:48 #305] Executed prepared statement changeset_current_lock in 21433 ms, returning 1 rows, 1 affected rows
    

    Maybe you could investigate in more detail, why both statements I mentioned above take so much time. I find this rather unusual.

  8. Rub21 commented on May 15, 2024

    @Rub21
    MemberAuthor

    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

    [2024-05-15T02:04:38 #307] Executed prepared statement get_user_id_pass in 0 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:04:38 #307] Executed prepared statement roles_for_user in 0 ms, returning 0 rows, 0 affected rows
    [2024-05-15T02:04:38 #307] Executed prepared statement check_user_blocked in 0 ms, returning 0 rows, 0 affected rows
    [2024-05-15T02:04:38 #307] Executed prepared statement is_user_active in 0 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:04:38 #307] Started request for changeset/upload 118113 from 10.10.47.154
    [2024-05-15T02:04:38 #307] Executed prepared statement changeset_exists in 6 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement changeset_current_lock in 124835 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement insert_tmp_create_nodes in 3 ms, returning 229 rows, 229 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement lock_current_nodes in 0 ms, returning 229 rows, 229 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement current_nodes_to_history in 6 ms, returning 0 rows, 229 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement current_node_tags_to_history in 1 ms, returning 0 rows, 0 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement calc_node_bbox in 0 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement insert_tmp_create_ways in 26 ms, returning 7651 rows, 7651 affected rows
    [2024-05-15T02:06:43 #307] Executed prepared statement lock_current_ways in 16 ms, returning 7651 rows, 7651 affected rows
    [2024-05-15T02:06:44 #307] Executed prepared statement lock_future_nodes_in_ways in 228 ms, returning 30226 rows, 30226 affected rows
    [2024-05-15T02:06:44 #307] Executed prepared statement insert_new_current_way_tags in 172 ms, returning 0 rows, 18061 affected rows
    [2024-05-15T02:06:45 #307] Executed prepared statement insert_new_current_way_nodes in 1071 ms, returning 0 rows, 50813 affected rows
    [2024-05-15T02:06:45 #307] Executed prepared statement current_ways_to_history in 112 ms, returning 0 rows, 7651 affected rows
    [2024-05-15T02:06:49 #307] Executed prepared statement current_way_tags_to_history in 4102 ms, returning 0 rows, 18061 affected rows
    [2024-05-15T02:07:25 #307] Executed prepared statement current_way_nodes_to_history in 35572 ms, returning 0 rows, 50813 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement calc_way_bbox in 26231 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement insert_tmp_create_relations in 3 ms, returning 34 rows, 34 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement lock_current_relations in 0 ms, returning 34 rows, 34 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement lock_future_ways_in_relations in 0 ms, returning 71 rows, 71 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement insert_new_current_relation_tags in 4 ms, returning 0 rows, 163 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement insert_new_current_relation_members in 5 ms, returning 0 rows, 71 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement current_relations_to_history in 6 ms, returning 0 rows, 34 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement current_relation_tags_to_history in 4 ms, returning 0 rows, 163 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement current_relation_members_to_history in 7 ms, returning 0 rows, 71 affected rows
    [2024-05-15T02:07:51 #307] Executed prepared statement calc_relation_bbox_nodes in 1 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:10:28 #307] Executed prepared statement calc_relation_bbox_ways in 157574 ms, returning 1 rows, 1 affected rows
    [2024-05-15T02:10:28 #307] Returning with http error 409 with reason The changeset 118113 was closed at 2024-05-15 02:04:38 UTC
    
  9. mmd-osm commented on May 15, 2024

    @mmd-osm

    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.

  10. Rub21 commented on May 15, 2024

    @Rub21
    MemberAuthor

    Yes, JOSM split the changeset into three chunks. The first two went okay, but the last one threw a 409 error.

  11. Rub21 commented on May 22, 2024

    @Rub21
    MemberAuthor

    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

  12. mmd-osm commented on May 23, 2024

    @mmd-osm

    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.

    2024-05-14 15:09:13.172 INFO: POST https://staging.openhistoricalmap.org/api/0.6/changeset/118102/upload -> HTTP/1.1 504 (1 min 0 s; 160 B)
    2024-05-14 15:09:13.177 INFO: Gateway Time-out
    
  13. 62 remaining items

  14. bitner commented on Jul 16, 2024

    @bitner

    @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.

  15. mmd-osm commented on Jul 16, 2024

    @mmd-osm

    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.

  16. bitner commented on Jul 16, 2024

    @bitner

    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

  17. mmd-osm commented on Jul 16, 2024

    @mmd-osm

    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.

  18. jeffreyameyer commented on Jul 17, 2024

    @jeffreyameyer
    Member
  19. Rub21 commented on Jul 17, 2024

    @Rub21
    MemberAuthor

    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=false and enable_hashjoin=false in 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.g

    EXPLAIN ANALYZE
    SELECT MIN(cn.latitude) AS minlat,
           MIN(cn.longitude) AS minlon,
           MAX(cn.latitude) AS maxlat,
           MAX(cn.longitude) AS maxlon
    FROM current_nodes cn
    INNER JOIN current_way_nodes wn
      ON cn.id = wn.node_id
                             
    INNER JOIN current_ways w
      ON wn.way_id = w.id
      
    INNER JOIN current_relation_members crm
      ON crm.member_id = w.id
                               
    
    WHERE crm.member_type = 'Way'
      AND crm.relation_id = ANY(
        ARRAY[
          2, 100, 2804190, 2804191, 2804192, 10000, 2804194, 2804195,
          2804196, 2804197, 2804198, 2804199, 2804200, 2804201, 2804202, 2804203,
          2804204, 2804205, 2804206, 2804207, 2804208, 2804209, 2804210, 2804211,
          2804212, 2804213, 2804214, 2804215, 2804216, 2804217, 2804218, 2804219,
          2804220, 2804221, 2804222, 2804223, 2804224, 2804225, 2804226, 2804227,
          2804228, 2804229, 2804230, 2804231, 2804232, 2804233, 2804234, 2804235,
          2804236, 2804237, 2804238, 2804239, 2804240, 2804241, 2804242, 2804243,
          2804244, 2804245, 2804246, 2804247, 2804248, 2804249, 2804250, 2804251,
          2804252, 2804253, 2804254, 2804255, 2804256, 2804257, 2804258, 2804259,
          2804260, 2804261, 2804262, 2804263, 2804264, 2804265, 2804266, 2804267,
          2804268, 2804269, 2804270, 2804271, 2804272, 2804273, 2804274, 2804275,
          2804276, 2804277, 2804278, 2804279, 2804280, 2804281, 2804282, 2804283,
          2804284, 2804285, 2804286, 2804287, 2804288, 2804289, 2804290, 2804291,
          2804292, 2804293, 2804294, 2804295, 2804296, 2804297, 2804298, 2804299,
          2804300, 2804301, 2804302, 2804303, 2804304, 2804305, 2804306, 2804307,
          2804308, 2804309, 2804310, 2804311, 2804312, 2804313, 2804314, 2804315,
          2804316, 2804317, 2804318, 2804319, 2804320, 2804321, 2804322, 2804323,
          2804324, 2804325, 2804326, 2804327, 2804328, 2804329, 2804330, 2804331,
          2804332, 2804333, 2804334, 2804335, 2804336, 2804337, 2804338, 2804339,
          2804340, 2804341, 2804342, 2804343, 2804344, 2804345, 2804346, 2804347,
          2804348, 2804349, 2804350, 2804351, 2804352, 2804353, 2804354, 2804355,
          2804356, 2804357, 2804358, 2804359, 2804360, 2804361, 2804362, 2804363,
          2804364, 2804365, 2804366, 2804367, 2804368, 2804369, 2804370, 2804371,
          2804372, 2804373, 2804374, 2804375, 2804376, 2804377, 2804378, 2804379,
          2804380, 2804381, 2804382, 2804383, 2804384, 2804385, 2804386, 2804387,
          2804388, 2804389, 2804390, 2804391, 2804392, 2804393, 2804394, 2804395,
          2804396, 2804397, 2804398, 2804399, 2804400, 2804401, 2804402, 2804403,
          2804404, 2804405, 2804406, 2804407, 2804408, 2804409, 2804410, 2804411,
          2804412, 2804413, 2804414, 2804415, 2804416, 2804417, 2804418, 2804419,
          2804420, 2804421, 2804422, 2804423, 2804424, 2804425, 2804426, 2804427,
          2804428, 2804429, 2804430, 2804431, 2804432, 2804433, 2804434, 2804435,
          2804436, 2804437, 2804438, 2804439, 2804440, 2804441, 2804442, 2804443,
          2804444, 2804445, 2804446, 2804447, 2804448
        ]
      );

    results:

    "QUERY PLAN"
    "Finalize Aggregate  (cost=26750133.37..26750133.38 rows=1 width=16) (actual time=1248.079..1255.039 rows=1 loops=1)"
    "  ->  Gather  (cost=26750133.14..26750133.35 rows=2 width=16) (actual time=1198.654..1255.003 rows=3 loops=1)"
    "        Workers Planned: 2"
    "        Workers Launched: 2"
    "        ->  Partial Aggregate  (cost=26749133.14..26749133.15 rows=1 width=16) (actual time=1124.344..1124.347 rows=1 loops=3)"
    "              ->  Nested Loop  (cost=1651.69..26650180.34 rows=9895280 width=8) (actual time=647.433..1113.335 rows=49619 loops=3)"
    "                    Join Filter: (wn.way_id = w.id)"
    "                    ->  Nested Loop  (cost=1651.25..26344125.71 rows=9895280 width=24) (actual time=647.371..1048.057 rows=49619 loops=3)"
    "                          ->  Nested Loop  (cost=1650.68..5052812.23 rows=9895280 width=24) (actual time=647.339..705.817 rows=49619 loops=3)"
    "                                ->  Parallel Bitmap Heap Scan on current_relation_members crm  (cost=1650.12..48372.43 rows=26536 width=8) (actual time=0.602..0.721 rows=274 loops=3)"
    "                                      Recheck Cond: ((relation_id = ANY ('{2,100,2804190,2804191,2804192,10000,2804194,2804195,2804196,2804197,2804198,2804199,2804200,2804201,2804202,2804203,2804204,2804205,2804206,2804207,2804208,2804209,2804210,2804211,2804212,2804213,2804214,2804215,2804216,2804217,2804218,2804219,2804220,2804221,2804222,2804223,2804224,2804225,2804226,2804227,2804228,2804229,2804230,2804231,2804232,2804233,2804234,2804235,2804236,2804237,2804238,2804239,2804240,2804241,2804242,2804243,2804244,2804245,2804246,2804247,2804248,2804249,2804250,2804251,2804252,2804253,2804254,2804255,2804256,2804257,2804258,2804259,2804260,2804261,2804262,2804263,2804264,2804265,2804266,2804267,2804268,2804269,2804270,2804271,2804272,2804273,2804274,2804275,2804276,2804277,2804278,2804279,2804280,2804281,2804282,2804283,2804284,2804285,2804286,2804287,2804288,2804289,2804290,2804291,2804292,2804293,2804294,2804295,2804296,2804297,2804298,2804299,2804300,2804301,2804302,2804303,2804304,2804305,2804306,2804307,2804308,2804309,2804310,2804311,2804312,2804313,2804314,2804315,2804316,2804317,2804318,2804319,2804320,2804321,2804322,2804323,2804324,2804325,2804326,2804327,2804328,2804329,2804330,2804331,2804332,2804333,2804334,2804335,2804336,2804337,2804338,2804339,2804340,2804341,2804342,2804343,2804344,2804345,2804346,2804347,2804348,2804349,2804350,2804351,2804352,2804353,2804354,2804355,2804356,2804357,2804358,2804359,2804360,2804361,2804362,2804363,2804364,2804365,2804366,2804367,2804368,2804369,2804370,2804371,2804372,2804373,2804374,2804375,2804376,2804377,2804378,2804379,2804380,2804381,2804382,2804383,2804384,2804385,2804386,2804387,2804388,2804389,2804390,2804391,2804392,2804393,2804394,2804395,2804396,2804397,2804398,2804399,2804400,2804401,2804402,2804403,2804404,2804405,2804406,2804407,2804408,2804409,2804410,2804411,2804412,2804413,2804414,2804415,2804416,2804417,2804418,2804419,2804420,2804421,2804422,2804423,2804424,2804425,2804426,2804427,2804428,2804429,2804430,2804431,2804432,2804433,2804434,2804435,2804436,2804437,2804438,2804439,2804440,2804441,2804442,2804443,2804444,2804445,2804446,2804447,2804448}'::integer[])) AND (member_type = 'Way'::nwr_enum))"
    "                                      Heap Blocks: exact=5"
    "                                      ->  Bitmap Index Scan on current_relation_members_pkey  (cost=0.00..1634.20 rows=63686 width=0) (actual time=1.668..1.668 rows=821 loops=1)"
    "                                            Index Cond: ((relation_id = ANY ('{2,100,2804190,2804191,2804192,10000,2804194,2804195,2804196,2804197,2804198,2804199,2804200,2804201,2804202,2804203,2804204,2804205,2804206,2804207,2804208,2804209,2804210,2804211,2804212,2804213,2804214,2804215,2804216,2804217,2804218,2804219,2804220,2804221,2804222,2804223,2804224,2804225,2804226,2804227,2804228,2804229,2804230,2804231,2804232,2804233,2804234,2804235,2804236,2804237,2804238,2804239,2804240,2804241,2804242,2804243,2804244,2804245,2804246,2804247,2804248,2804249,2804250,2804251,2804252,2804253,2804254,2804255,2804256,2804257,2804258,2804259,2804260,2804261,2804262,2804263,2804264,2804265,2804266,2804267,2804268,2804269,2804270,2804271,2804272,2804273,2804274,2804275,2804276,2804277,2804278,2804279,2804280,2804281,2804282,2804283,2804284,2804285,2804286,2804287,2804288,2804289,2804290,2804291,2804292,2804293,2804294,2804295,2804296,2804297,2804298,2804299,2804300,2804301,2804302,2804303,2804304,2804305,2804306,2804307,2804308,2804309,2804310,2804311,2804312,2804313,2804314,2804315,2804316,2804317,2804318,2804319,2804320,2804321,2804322,2804323,2804324,2804325,2804326,2804327,2804328,2804329,2804330,2804331,2804332,2804333,2804334,2804335,2804336,2804337,2804338,2804339,2804340,2804341,2804342,2804343,2804344,2804345,2804346,2804347,2804348,2804349,2804350,2804351,2804352,2804353,2804354,2804355,2804356,2804357,2804358,2804359,2804360,2804361,2804362,2804363,2804364,2804365,2804366,2804367,2804368,2804369,2804370,2804371,2804372,2804373,2804374,2804375,2804376,2804377,2804378,2804379,2804380,2804381,2804382,2804383,2804384,2804385,2804386,2804387,2804388,2804389,2804390,2804391,2804392,2804393,2804394,2804395,2804396,2804397,2804398,2804399,2804400,2804401,2804402,2804403,2804404,2804405,2804406,2804407,2804408,2804409,2804410,2804411,2804412,2804413,2804414,2804415,2804416,2804417,2804418,2804419,2804420,2804421,2804422,2804423,2804424,2804425,2804426,2804427,2804428,2804429,2804430,2804431,2804432,2804433,2804434,2804435,2804436,2804437,2804438,2804439,2804440,2804441,2804442,2804443,2804444,2804445,2804446,2804447,2804448}'::integer[])) AND (member_type = 'Way'::nwr_enum))"
    "                                ->  Index Scan using current_way_nodes_pkey on current_way_nodes wn  (cost=0.57..184.86 rows=373 width=16) (actual time=0.008..0.154 rows=181 loops=821)"
    "                                      Index Cond: (way_id = crm.member_id)"
    "                          ->  Index Scan using current_nodes_pkey1 on current_nodes cn  (cost=0.57..2.15 rows=1 width=16) (actual time=0.006..0.006 rows=1 loops=148857)"
    "                                Index Cond: (id = wn.node_id)"
    "                    ->  Memoize  (cost=0.44..1.23 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=148857)"
    "                          Cache Key: crm.member_id"
    "                          Cache Mode: logical"
    "                          Hits: 81280  Misses: 98  Evictions: 0  Overflows: 0  Memory Usage: 11kB"
    "                          Worker 0:  Hits: 19582  Misses: 62  Evictions: 0  Overflows: 0  Memory Usage: 7kB"
    "                          Worker 1:  Hits: 47629  Misses: 206  Evictions: 0  Overflows: 0  Memory Usage: 23kB"
    "                          ->  Index Only Scan using current_ways_pkey on current_ways w  (cost=0.43..1.22 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=366)"
    "                                Index Cond: (id = crm.member_id)"
    "                                Heap Fetches: 366"
    "Planning Time: 1.434 ms"
    "JIT:"
    "  Functions: 71"
    "  Options: Inlining true, Optimization true, Expressions true, Deforming true"
    "  Timing: Generation 15.083 ms, Inlining 523.234 ms, Optimization 758.446 ms, Emission 658.234 ms, Total 1954.996 ms"
    "Execution Time: 1257.587 ms"
    

    @batpad I’d like to know your thoughts on this approach?

  20. batpad commented on Jul 17, 2024

    @batpad

    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.

    I've adjusted the statistics levels for the key columns used in the joins and force ran ANALYZE for the tables involved in the join and now get a much saner plan.

    Is this something we should setup to run on a regular basis or so?

    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

    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.

    Setting enable_mergejoin=false and enable_hashjoin=false in 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.

    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=false and enable_hashjoin=false fixes the issue, I would advocate for just doing this.

  21. Rub21 commented on Jul 17, 2024

    @Rub21
    MemberAuthor

    @batpad @jeffreyameyer I've just set up the values in the production DB,

    set enable_mergejoin=false;
    set enable_hashjoin=false;
    SELECT pg_reload_conf();

    It should be ok now!

  22. jeffreyameyer commented on Jul 18, 2024

    @jeffreyameyer
    Member

    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:
    Monosnap Communication with OSM server failed 2024-07-17 21-23-06

  23. jeffreyameyer commented on Jul 18, 2024

    @jeffreyameyer
    Member

    Now this:
    Monosnap IO Exception 2024-07-17 21-48-53

    And the website is still down.

  24. Rub21 commented on Jul 18, 2024

    @Rub21
    MemberAuthor

    Weird, timeout for ingress is set up for 20 min and 200MB,

    Annotations:                 cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
                                 kubernetes.io/ingress.class: nginx
                                 meta.helm.sh/release-name: production
                                 meta.helm.sh/release-namespace: default
                                 nginx.ingress.kubernetes.io/proxy-body-size: 200m
                                 nginx.ingress.kubernetes.io/proxy-connect-timeout: 1200
                                 nginx.ingress.kubernetes.io/proxy-read-timeout: 1200
                                 nginx.ingress.kubernetes.io/proxy-send-timeout: 1200
    

    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.

  25. Rub21 commented on Jul 18, 2024

    @Rub21
    MemberAuthor

    The cgimap query issue has been fixed. Closing this ticket and opening a new ticket to discuss the heavy load on the website: #850

  26. added theissue type on Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions