Long Query Error & 502 Bad Gateway Eror

Home Forums Calendar Products Events Calendar PRO Long Query Error & 502 Bad Gateway Eror

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #877508
    Zachary
    Participant

    We see lots of long query errors in our logs. We also see lots of 502 Bad Gateway errors. I am not certain the two are related, but this is my suspicion. I think it may be the case that the long queries are bogging the server down, which makes it unable to serve pages—thus the 502s. Interestingly, the 502s are not generally seen on the events page but on random pages on a subsite of our multisite network.

    We don’t have very many events. Maybe a few dozen, none recurring. Our site is hosted on WP Engine at the “Professional” tier. This should be more than enough to handle our traffic.

    I see that there are several threads related to issues with the Events Calendar on WP Engine hosted sites, however I haven’t been able to find any that give solutions. The closest I’ve seen is this thread from this July [https://tri.be/support/forums/topic/abandoning-events-calendar-pro/], in which Caleb wrote that the issue could be resolved by removing the limit on WPEngine’s side:
    ========
    This is a known issue with WP Engine, since they limit the length of SQL queries. Try adding the following to your wp-config.php file, which should hopefully disable that limit in WP Engine:
    define( ‘WPE_GOVERNOR’, false );
    ========
    I asked WPEngine if I should do this, and they said that this would prevent the error from being logged but would not prevent the error itself. So I don’t think that will solve my issue.

    So far I’ve updated both Tribe calendar plugins, updated WordPress, deactivated and deleted Events Calendar Pro, and removed the plugin from a sub-site (blazingmountain.org). Still seeing the long query errors.

    So my main question is how do I get the plugin to stop generating these long query errors. My secondary question: Do you think the long query could be related to the 502 errors.

    I love the plugin! Please help me figure out how to make it work for my site. Thanks!

    #878065
    Barry
    Member

    Hi Zachary,

    Thanks for getting in touch.

    The closest I’ve seen is this thread from this July [https://tri.be/support/forums/topic/abandoning-events-calendar-pro/], in which Caleb wrote that the issue could be resolved by removing the limit on WPEngine’s side:
    ========
    This is a known issue with WP Engine, since they limit the length of SQL queries. Try adding the following to your wp-config.php file, which should hopefully disable that limit in WP Engine:
    define( ‘WPE_GOVERNOR’, false );
    ========
    I asked WPEngine if I should do this, and they said that this would prevent the error from being logged but would not prevent the error itself. So I don’t think that will solve my issue.

    Exactly so: stopping those queries from being logged won’t prevent the queries from happening so it’s all to the good that they are logged.

    WP Engine log long queries for valid reasons but it is definitely worth keeping in mind that a long query in of itself is not necessarily a poorly performing one – its just a potential indicator of problems.

    We don’t have very many events. Maybe a few dozen, none recurring. Our site is hosted on WP Engine at the “Professional” tier. This should be more than enough to handle our traffic.

    It certainly sounds like you have ample resources, especially for such a small number of events. Of course, one thing I don’t know is how much traffic your site is receiving – but let’s proceed on the assumption that it isn’t excessive given available resources.

    So my main question is how do I get the plugin to stop generating these long query errors. My secondary question: Do you think the long query could be related to the 502 errors.

    Basically, there is no particular way for you to stop these long query errors – which might more properly be described as warnings (nothing is necessarily going wrong and longer queries can in fact be better performing queries, depending on the context).

    I am curious about the 502 errors, though, particularly given your other note:

    Interestingly, the 502s are not generally seen on the events page but on random pages on a subsite of our multisite network.

    Are you able to replicate the same problems on your staging site? If so, can you run through our standard troubleshooting/conflict test steps and potentially eliminate the potential for a conflict stemming from another plugin?

    It definitely isn’t unknown for our plugin to generate long query warnings – but the fact that you have only a dozen or so events raises something of a warning flag in my mind (I wouldn’t actually expect our plugins by themselves to trigger these warnings with so few events) … might some other plugin, or your theme, be impacting on the query?

    Can you share one of the actual queries in question?

    Thanks!

    #879695
    Zachary
    Participant

    Hi Barry,
    Thanks for responding. Here is one of the long query errors:

    [Tue Nov 11 09:59:42 2014] [error] [client 85.113.166.57] LONG QUERY (1152 characters long generated in /nas/wp/www/cluster-2802/dharmaocean/wp-content/plugins/the-events-calendar/lib/tribe-event-query.class.php:786): \n\t\t\t\t\t\t\tSELECT \ttribe_event_start.post_id as ID, \n\t\t\t\t\t\t\t\t\ttribe_event_start.meta_value as EventStartDate, \n\t\t\t\t\t\t\t\t\tDATE_FORMAT( tribe_event_end_date.meta_value, ‘%Y-%m-%d %H:%i:%s’) as EventEndDate,\n\t\t\t\t\t\t\t\t\twp_2_posts.menu_order as menu_order\n\t\t\t\t\t\t\tFROM wp_2_postmeta AS tribe_event_start\n\t\t\t\t\t\t\t\t\tLEFT JOIN wp_2_posts ON (tribe_event_start.post_id = wp_2_posts.ID)\n\t\t\t\t\t\t\tLEFT JOIN wp_2_postmeta as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = ‘_EventEndDate’ )\n\t\t\t\t\t\t\tWHERE tribe_event_start.meta_key = ‘_EventStartDate’\n\t\t\t\t\t\t\tAND tribe_event_start.post_id IN ( 231 )\n\t\t\t\t\t\t\tAND ( (tribe_event_start.meta_value >= ‘2014-11-01 00:00:00’ AND tribe_event_start.meta_value <= ‘2014-11-30 23:59:59’)\n\t\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= ‘2014-11-01 00:00:00’ AND tribe_event_end_date.meta_value >= ‘2014-11-01 00:00:00’)\n\t\t\t\t\t\t\t\tOR ( tribe_event_start.meta_value >= ‘2014-11-01 00:00:00’ AND tribe_event_start.meta_value <= ‘2014-11-30 23:59:59’)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tORDER BY menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;, referer: http://www.blazingmountain.org/location/about-the-environment/

    You can see that the “referer” is the site blazingmountain.org. This is a sub-site on our multi-site network. As mentioned in my first post I removed the calendar from this site, but I’m still seeing the errors. Here’s another, which was logged after removing the celendar from the sub-site:

    [Tue Nov 11 19:44:59 2014] [error] [client 71.196.153.209] LONG QUERY (1043 characters long generated in /nas/wp/www/cluster-2802/dharmaocean/wp-content/plugins/the-events-calendar/lib/tribe-event-query.class.php:887): SELECT DISTINCT wp_2_posts.*, MIN(wp_2_postmeta.meta_value) as EventStartDate, MIN(tribe_event_end_date.meta_value) as EventEndDate FROM wp_2_posts INNER JOIN wp_2_postmeta ON (wp_2_posts.ID = wp_2_postmeta.post_id) LEFT JOIN wp_2_postmeta as tribe_event_end_date ON ( wp_2_posts.ID = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = ‘_EventEndDate’ ) WHERE 1=1 AND wp_2_posts.ID IN (231) AND wp_2_posts.post_type = ‘tribe_events’ AND (wp_2_posts.post_status = ‘publish’ OR wp_2_posts.post_status = ‘private’) AND (wp_2_postmeta.meta_key = ‘_EventStartDate’ ) AND ((wp_2_postmeta.meta_value >= ‘2014-11-13 00:00:00’ AND wp_2_postmeta.meta_value <= ‘2014-11-13 23:59:59’) OR (tribe_event_end_date.meta_value >= ‘2014-11-13 00:00:00’ AND wp_2_postmeta.meta_value <= ‘2014-11-13 23:59:59’ ) OR (wp_2_postmeta.meta_value < ‘2014-11-13 00:00:00’ AND tribe_event_end_date.meta_value >= ‘2014-11-13 23:59:59’ )) GROUP BY wp_2_posts.ID ORDER BY DATE(MIN(wp_2_postmeta.meta_value)) ASC, TIME(wp_2_postmeta.meta_value) ASC LIMIT 0, 3

    This is all more or less gobbledegook to me, so perhaps you can help me make sense of it. Is there any way to tell from these errors where to look for the issue?

    Thank you for your suggestion to test on the staging site with the basic twenty-something theme. The thing is we don’t really see the errors on the staging site even with the same configuration as the live site. The staging site doesn’t get much traffic, of course, and so I don’t know how to reproduce an issue on staging that only seems to rear its head under real world use. Any advice here?

    #882205
    Barry
    Member

    Pretty puzzling.

    So, putting the referer part of the first log entry aside for the moment (I’m concerned that may be a little misleading), do you know that those log entries relate to this particular subsite? Or is this a general log for the site/network as a whole?

    As in my first reply, it’s important also to remember that a LONG QUERY warning is a potential indicator of problems – but isn’t always a reliable one. The fact that they are a little longer than a very simple select statement doesn’t necessarily mean they are poorly performing as a consequence.

    Given you are experiencing the actual 502s on random, non-event related pages of this particular subsite I wonder if you need to look elsewhere for the source of this problem … as the fact is these queries and the presence of our plugins on your network may have nothing to do with the problem.

    • If the 502s are specific to one subsite that doesn’t make use of The Events Calendar, have you been able to explore something basically similar to our own standard troubleshooting steps but in relation to other plugins/your theme?
    • Could you touch base with WP Engine and ask if the logging of queries could be tweaked to include the length of time they take to complete?
    • If you can’t get anywhere with the above then, as a last-ditch troubleshooting measure, could you even temporarily deactivate our plugins – place a suitable “The calendar will be live again soon” notice up or something similar – and see if the 502s continue or abate?

    Thanks for bearing with us, here. It’s a tricky thing to troubleshoot particularly given the specific nature of the problem on your network  – but hopefully between us and your host we can help you to uncover a few answers 🙂

    #904487
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Long Query Error & 502 Bad Gateway Eror’ is closed to new replies.