Page MenuHomePhabricator

ShortUrl must not perform write query (or not throw DBReadOnlyError) on regular page views
Closed, ResolvedPublic

Description

When viewing https://test2.wikipedia.org/wiki/1968年臺灣 in codfw (mw2099.codfw.wmnet) I noticed the following

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 - the error that does bubble is 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

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 277819 had a related patch set uploaded (by Aaron Schulz):
Handle read-only mode

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

This would only have happened for pages already created that nobody has visited yet. So, while it disfigured the page, I think it was unlikely to happen much on wikis that have had ShortUrl turned on for a while.

Change 277819 merged by jenkins-bot:
Handle read-only mode

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

Gilles claimed this task.
Gilles closed this task as Resolved.