Up until recently, PHP requests had no time out limit. Tim Starling fixed this. This exposes a few problems with certain pages rendering on mobile.
LazyImageTransform times out on complicated pages. Our error log says:
Fatal error: entire web request took longer than 60 seconds and timed out in /srv/mediawiki/php-1.32.0-wmf.20/extensions/MobileFrontend/includes/transforms/LazyImageTransform.php on line 177
or
PHP Fatal Error from line 112 of /srv/mediawiki/php-1.32.0-wmf.20/extensions/MobileFrontend/includes/MobileContext.php: entire web request took longer than 60 seconds and timed out
Example stacktrace:
#0 /srv/mediawiki/php-1.32.0-wmf.20/extensions/MobileFrontend/includes/MobileContext.php(112): NO_FUNCTION_GIVEN() #1 /srv/mediawiki/php-1.32.0-wmf.20/extensions/MobileFrontend/includes/MobileFrontend.hooks.php(513): MobileContext::singleton() #2 /srv/mediawiki/php-1.32.0-wmf.20/extensions/MobileFrontend/includes/MobileFrontend.hooks.php(541): MobileFrontendHooks::shouldMobileFormatSpecialPages(User) #3 /srv/mediawiki/php-1.32.0-wmf.20/includes/Hooks.php(174): MobileFrontendHooks::onSpecialPageInitList(array) #4 /srv/mediawiki/php-1.32.0-wmf.20/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL) #5 /srv/mediawiki/php-1.32.0-wmf.20/includes/specialpage/SpecialPageFactory.php(281): Hooks::run(string, array) #6 /srv/mediawiki/php-1.32.0-wmf.20/includes/specialpage/SpecialPageFactory.php(297): MediaWiki\Special\SpecialPageFactory->getPageList() #7 /srv/mediawiki/php-1.32.0-wmf.20/includes/specialpage/SpecialPageFactory.php(662): MediaWiki\Special\SpecialPageFactory->getAliasList() #8 /srv/mediawiki/php-1.32.0-wmf.20/includes/specialpage/SpecialPage.php(99): MediaWiki\Special\SpecialPageFactory->getLocalNameFor(string, boolean) #9 /srv/mediawiki/php-1.32.0-wmf.20/includes/specialpage/SpecialPage.php(85): SpecialPage::getTitleValueFor(string, boolean, string) #10 /srv/mediawiki/php-1.32.0-wmf.20/skins/MinervaNeue/includes/skins/SkinMinerva.php(620): SpecialPage::getTitleFor(string) #11 /srv/mediawiki/php-1.32.0-wmf.20/skins/MinervaNeue/includes/skins/SkinMinerva.php(1248): SkinMinerva->getDiscoveryTools() #12 /srv/mediawiki/php-1.32.0-wmf.20/skins/MinervaNeue/includes/skins/SkinMinerva.php(1269): SkinMinerva->getMenuData() #13 /srv/mediawiki/php-1.32.0-wmf.20/skins/MinervaNeue/includes/skins/SkinMinerva.php(342): SkinMinerva->getSkinConfigVariables() #14 /srv/mediawiki/php-1.32.0-wmf.20/includes/skins/SkinTemplate.php(224): SkinMinerva->initPage(OutputPage) #15 /srv/mediawiki/php-1.32.0-wmf.20/includes/OutputPage.php(2402): SkinTemplate->outputPage() #16 /srv/mediawiki/php-1.32.0-wmf.20/includes/MediaWiki.php(875): OutputPage->output(boolean) #17 /srv/mediawiki/php-1.32.0-wmf.20/includes/MediaWiki.php(887): Closure$MediaWiki::main() #18 /srv/mediawiki/php-1.32.0-wmf.20/includes/MediaWiki.php(525): MediaWiki->main() #19 /srv/mediawiki/php-1.32.0-wmf.20/index.php(42): MediaWiki->run() #20 /srv/mediawiki/w/index.php(3): include(string) #21 {main}
Between September 10th and September 17th, there were 42 occurrences of the timed out request.
Developer notes
Options
Drop support for certain namespaces
We could not run the LazyImageTransform on pages with this many images.
Given this is only impacting user pages and the lazy image transform predominately was written for articles in the main namespace, I think it's acceptable to limit this transform to NS_MAIN or to blacklist the NS_USER namespace.
Trade offs: It's working fine in all of those other namespaces
Acceptance criteria
- The LazyImageTransform only runs on namespaces it has been configured to run on.
- It is does not run on NS_USER
- It runs on NS_MAIN (main namespace)
Limit number of images
Risky change - but we could count images on a page and not run the transform. This would help this one case, but there may be other reasons the MobileFormatter (which is expensive) doesn't finish
Category/title blacklist
We could not run the formatter on pages which have a special category (that is hidden) that marks pages as not being suitable for mobile formatting. This would provide us a way to remove pages with performance issues like this one.
Spike questions
Output: A comment in this task. As part of sign off a concrete actionable task should be created.
Using logstash
- For the pages that exhibit the problem is there anything common to them? e.g. namespace/number of images/size of document?
- How many pages are we talking?
Techniques for disabling formatting
- Explore techniques for identifying and disabling the MobileFormatter on large pages.
- Can we count number of images? How? Regex? Any page properties we can use?
- Is there any way we can defer the page formatting to the job queue?