Page MenuHomePhabricator

DBReadOnlyError causes broken double page rendering
Closed, ResolvedPublic

Description

When testing something in codfw (via X-Wikimedia-Debug) I got the following when visiting a random page.

Screen Shot 2016-03-11 at 16.50.43.png (1×2 px, 677 KB)

Screen Shot 2016-03-11 at 16.52.16.png (1×2 px, 704 KB)

https://test2.wikipedia.org/wiki/1968年臺灣 (mw2099.codfw.wmnet)

Original exception: [1ececc4b] /wiki/1968%E5%B9%B4%E8%87%BA%E7%81%A3 DBReadOnlyError from line 789 of /srv/mediawiki/php-1.27.0-wmf.16/includes/db/Database.php: Database is read-only: Mediawiki is in read-only mode during maintenance, please try again in 15 minutes
Backtrace:
#0 /srv/mediawiki/php-1.27.0-wmf.16/includes/db/Database.php(1463): DatabaseBase->query(string, string)
#1 /srv/mediawiki/php-1.27.0-wmf.16/extensions/ShortUrl/ShortUrl.utils.php(54): DatabaseBase->insert(string, array, string, string)
#2 /srv/mediawiki/php-1.27.0-wmf.16/extensions/ShortUrl/ShortUrl.hooks.php(44): ShortUrlUtils::encodeTitle(Title)
#3 /srv/mediawiki/php-1.27.0-wmf.16/includes/Hooks.php(195): ShortUrlHooks::addToolboxLink(VectorTemplate, boolean)
#4 /srv/mediawiki/php-1.27.0-wmf.16/skins/Vector/VectorTemplate.php(319): Hooks::run(string, array)
#5 /srv/mediawiki/php-1.27.0-wmf.16/skins/Vector/VectorTemplate.php(273): VectorTemplate->renderPortal(string, array, string, string)
#6 /srv/mediawiki/php-1.27.0-wmf.16/skins/Vector/VectorTemplate.php(195): VectorTemplate->renderPortals(array)
#7 /srv/mediawiki/php-1.27.0-wmf.16/includes/skins/SkinTemplate.php(240): VectorTemplate->execute()
#8 /srv/mediawiki/php-1.27.0-wmf.16/includes/OutputPage.php(2363): SkinTemplate->outputPage()
#9 /srv/mediawiki/php-1.27.0-wmf.16/includes/MediaWiki.php(746): OutputPage->output()
#10 /srv/mediawiki/php-1.27.0-wmf.16/includes/MediaWiki.php(519): MediaWiki->main()
#11 /srv/mediawiki/php-1.27.0-wmf.16/index.php(43): MediaWiki->run()
#12 /srv/mediawiki/w/index.php(3): include(string)
#13 {main}

Exception caught inside exception handler: [0b006398] /wiki/1968%E5%B9%B4%E8%87%BA%E7%81%A3 DBReadOnlyError from line 789 of /srv/mediawiki/php-1.27.0-wmf.16/includes/db/Database.php: Database is read-only: Mediawiki is in read-only mode during maintenance, please try again in 15 minutes
Backtrace:
#0 /srv/mediawiki/php-1.27.0-wmf.16/includes/db/Database.php(1463): DatabaseBase->query(string, string)
#1 /srv/mediawiki/php-1.27.0-wmf.16/extensions/ShortUrl/ShortUrl.utils.php(54): DatabaseBase->insert(string, array, string, string)
#2 /srv/mediawiki/php-1.27.0-wmf.16/extensions/ShortUrl/ShortUrl.hooks.php(44): ShortUrlUtils::encodeTitle(Title)
#3 /srv/mediawiki/php-1.27.0-wmf.16/includes/Hooks.php(195): ShortUrlHooks::addToolboxLink(VectorTemplate, boolean)
#4 /srv/mediawiki/php-1.27.0-wmf.16/skins/Vector/VectorTemplate.php(319): Hooks::run(string, array)
#5 /srv/mediawiki/php-1.27.0-wmf.16/skins/Vector/VectorTemplate.php(273): VectorTemplate->renderPortal(string, array, string, string)
#6 /srv/mediawiki/php-1.27.0-wmf.16/skins/Vector/VectorTemplate.php(195): VectorTemplate->renderPortals(array)
#7 /srv/mediawiki/php-1.27.0-wmf.16/includes/skins/SkinTemplate.php(240): VectorTemplate->execute()
#8 /srv/mediawiki/php-1.27.0-wmf.16/includes/OutputPage.php(2363): SkinTemplate->outputPage()
#9 /srv/mediawiki/php-1.27.0-wmf.16/includes/exception/MWException.php(204): OutputPage->output()
#10 /srv/mediawiki/php-1.27.0-wmf.16/includes/exception/MWException.php(244): MWException->reportHTML()
#11 /srv/mediawiki/php-1.27.0-wmf.16/includes/exception/MWExceptionHandler.php(69): MWException->report()
#12 /srv/mediawiki/php-1.27.0-wmf.16/includes/exception/MWExceptionHandler.php(180): MWExceptionHandler::report(DBReadOnlyError)
#13 /srv/mediawiki/php-1.27.0-wmf.16/includes/MediaWiki.php(528): MWExceptionHandler::handleException(DBReadOnlyError)
#14 /srv/mediawiki/php-1.27.0-wmf.16/index.php(43): MediaWiki->run()
#15 /srv/mediawiki/w/index.php(3): include(string)
#16 {main}

Aside from the fact that something is trying to do a write on a page view, over GET, in read-only mode, and not catching it - (see T129658 for that) - the error that does happen is also breaking the page layout. Seems like it happens very late in the request cycle but still before the response is closed, so the user gets two (or three) full html responses mixed up on top of each other.

Event Timeline

To confirm, the same is not limited to page views. The same happens when DBReadOnlyError is thrown from e.g. action=markpatrolled.

Screen Shot 2016-03-11 at 17.08.54.png (1×1 px, 441 KB)

Gilles claimed this task.
Gilles subscribed.
This comment was removed by Gilles.

Change 278339 had a related patch set uploaded (by Aaron Schulz):
Avoid double-rendering on late exceptions

https://gerrit.wikimedia.org/r/278339

Krinkle claimed this task.

With the above OutputPage patch applied (and the ShortUrl patch reverted locally as example test case), the output renders as follows:

Screen Shot 2016-03-29 at 23.21.25.png (1×2 px, 788 KB)

Previously it would've been like this:

Screen Shot 2016-03-29 at 23.21.35.png (1×1 px, 577 KB)

Change 278339 merged by jenkins-bot:
Avoid double-rendering on late exceptions

https://gerrit.wikimedia.org/r/278339