Hi.

I'm trying to create a view that exports calendar events in the iCal format using the date iCal module. I'm experiencing a problem when i try to export more than 90 events i get a timeout and no results are returned. The query run is extremely simple so i doubt that that is the bottleneck!?

I'm not at all sure wether this problem relates to the Date iCal module but it seems as the natural place to start looking.

The query run:

SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, node.created AS node_created, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_event_date_node_entity_type, 'node' AS field_data_field_locsec_area_node_entity_type
FROM 
{node} node
LEFT JOIN {field_data_field_event_date} field_data_field_event_date ON node.nid = field_data_field_event_date.entity_id AND (field_data_field_event_date.entity_type = 'node' AND field_data_field_event_date.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('events')) AND (DATE_FORMAT(ADDTIME(field_data_field_event_date.field_event_date_value, SEC_TO_TIME(7200)), '%Y-%m-%d\T%H') >= '2017-04-22T14') ))
ORDER BY node_created DESC

Here is the error message i get when i try to download the .ics file:

Fatal error: Maximum execution time of 60 seconds exceeded in /var/www/sitename/sites/all/modules/contrib/date/date_api/date_api.module on line 650

Comments

RasmusKnabe created an issue.

coredumperror’s picture

90 events should definitely not be taking that long to export as iCal. I have successfully exported iCal feeds with this module that have thousands of events in just a few seconds.

Since no one else has ever reported this problem, my first guess would be that you have another module installed that is interfering with the operation of Date iCal. Perhaps it's hooking a very slow function into your Views that plays especially poorly with the iCal exporter?

Have you checked your error logs to see if anything is spewing errors? that could also massively slow down the export operation.

rasmusknabe@gmail.com’s picture

Thank's for your answer.

I don't see any errors in Drupal's log - Any idea how i proceed debugging this?

By the way, i have disabled SQL rewriting on the view so i guess it should skip all access parameters in Drupal (but not sure how that works exactly).

coredumperror’s picture

I would suggest disabling one module at a time that you think might possibly have any sort of hooks into Views, then trying again for each disabled module. I think it's likely that you'd eventually remove that slowdown, and then you'll know which module was causing it.

rasmusknabe@gmail.com’s picture

I have now tried to disable alle modules other than the ones needed for date iCal to work, and i still have the same problem!?

Was thinking it might be due to af misconfiguration on the server or PHP but as far as i can read the iCalCreator library needs php >= 5.2.0 and I'm running 5.6.25

The only thing i can come up with now is to see if i can recreate the problem on a clean install of Drupal.

coredumperror’s picture

Hmm, that's unfortunate. I was really hoping that your performance problem would be solved by that disabling step.

Do any other views have this slowness problem? Or is it just iCal export views?

I think installing a fresh Drupal might help narrow down the problem. But if even that doesn't work, perhaps there's something external to Drupal that's messed up? Maybe your database is being slow?

rasmusknabe@gmail.com’s picture

Me too, especially since it took me almost 5 hours to do :)

I don't experience slow views elsewhere and i have another view that exports ~1800 members, with their address and more as a CSV file in a couple of seconds. But that's using the "views data export" module which utilises the batch API.

If i copy paste the SQL from my iCal export feed and run it directly from an SQL client i returns the results in 50ms, so the database doesn't seem slow either.

However i tried to change my iCal export feed to be an RSS feed using fields, and here i have the same problem with the timeout!?

coredumperror’s picture

Wow, that's extra bizarre! Though it does seem to point to something being wrong that's unrelated to Date iCal. So that's at least a minor clue.

Have you tried deleting the view entirely, and starting from scratch? Views can be pretty quirky like that, sometimes.

rasmusknabe@gmail.com’s picture

Yes, i agre that it seems to be unrelated to the Date iCal module.

I just have to keep digging a bit :)

rasmusknabe@gmail.com’s picture

I have no idea why but for some reason it's now working as expected!?

Haven't done any changes to the Prod site but I'm now able to export all calendar events in a few sec.

coredumperror’s picture

Bizarre. Could it have been a caching issue, maybe? When things clear up on their own for no apparent reason, that often seems to be the cause.

rasmusknabe@gmail.com’s picture

It gets even more bizzare!

A week ago i made a local copy of the Prod site - A complete copy of the files and database. I then tried to disable and uninstall all modules one by one, without any result.

Now the Prod site suddenly works but my local copy thats only a week old still dosen't work!

I haven't changed anything on Prod in that period.

(When developing or debugging i flush the cache every other minute :) )

coredumperror’s picture

Maybe it's browser-side caching? Though now that's seeming like more of a long shot.

I'm still totally baffled here, both as to the cause of the problem, and the eventual resolution.

imclean’s picture

We're seeing something similar. Running the SQL query on the DB returns the results almost instantly. Using an iCal Feeds display in Views it take 15 to 20 seconds. I'm using XHProf to help diagnose the issue.

Most of the time seems to be taken up within the Views Render stage. A few seconds are spent in date_ical_plugin_style_ical_feed::render. I also suspect formatting and rendering the date field may be taking up a bit of time.

imclean’s picture

I've worked around the issue using caching. Specifically, the module Views content cache, making sure the rendered output is cached. See the documentation.