Page MenuHomePhabricator

Fatal on Preferences and ApiOptions with "Lock wait timeout exceeded" from User::getInstanceForUpdate
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

Request ID: W6mc6wrAIDsAAAYf85wAAAAM

Preferences save
Query: SELECT  user_id,user_name,user_real_name,user_email,user_touched,user_token,user_email_authenticated,user_email_token,user_email_token_expires,user_registration,user_editcount  FROM `user`    WHERE user_id = '####'  LIMIT 1   FOR UPDATE
Function: User::loadFromDatabase
Error: 1205 Lock wait timeout exceeded; try restarting transaction

#1 /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php(1198): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php(1655): Wikimedia\Rdbms\Database->query(string, string)
#3 /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php(1746): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#4 /srv/mediawiki/php-1.32.0-wmf.22/includes/user/User.php(1449): Wikimedia\Rdbms\Database->selectRow(array, array, array, string, array, array)
#5 /srv/mediawiki/php-1.32.0-wmf.22/includes/user/User.php(475): User->loadFromDatabase(integer)
#6 /srv/mediawiki/php-1.32.0-wmf.22/includes/user/User.php(5701): User->loadFromId(integer)
#7 /srv/mediawiki/php-1.32.0-wmf.22/includes/specials/SpecialPreferences.php(107): User->getInstanceForUpdate()
#8 /srv/mediawiki/php-1.32.0-wmf.22/includes/specialpage/SpecialPage.php(569): SpecialPreferences->execute(NULL)
#9 /srv/mediawiki/php-1.32.0-wmf.22/includes/specialpage/SpecialPageFactory.php(581): SpecialPage->run(NULL)
#10 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#11 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(868): MediaWiki->performRequest()
#12 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(525): MediaWiki->main()
#13 /srv/mediawiki/php-1.32.0-wmf.22/index.php(42): MediaWiki->run()

Request ID: W7P4uQrAAFEAABYC@swAAADK

name=ApiOptions save,limit=10
A database query error has occurred. Query: SELECT  user_id,user_name,user_real_name,user_email,user_touched,user_token,user_email_authenticated,user_email_token,user_email_token_expires,user_registration,user_editcount  FROM `user`    WHERE user_id = '####'  LIMIT 1   FOR UPDATE

Function: User::loadFromDatabase
Error: 1205 Lock wait timeout exceeded; try restarting transaction

#0 /srv/mediawiki/php-1.32.0-wmf.23/includes/libs/rdbms/database/Database.php(1428): Wikimedia\Rdbms\Database->makeQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.32.0-wmf.23/includes/libs/rdbms/database/Database.php(1198): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /srv/mediawiki/php-1.32.0-wmf.23/includes/libs/rdbms/database/Database.php(1655): Wikimedia\Rdbms\Database->query(string, string)
#3 /srv/mediawiki/php-1.32.0-wmf.23/includes/libs/rdbms/database/Database.php(1746): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#4 /srv/mediawiki/php-1.32.0-wmf.23/includes/user/User.php(1449): Wikimedia\Rdbms\Database->selectRow(array, array, array, string, array, array)
#5 /srv/mediawiki/php-1.32.0-wmf.23/includes/user/User.php(475): User->loadFromDatabase(integer)
#6 /srv/mediawiki/php-1.32.0-wmf.23/includes/user/User.php(5701): User->loadFromId(integer)
#7 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiOptions.php(136): User->getInstanceForUpdate()
#8 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiOptions.php(39): ApiOptions->getUserForUpdates()
#9 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMain.php(1587): ApiOptions->execute()
#10 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMain.php(531): ApiMain->executeAction()
#11 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#12 /srv/mediawiki/php-1.32.0-wmf.23/api.php(87): ApiMain->execute()

Notes

This is one of the most common Database errors at the moment.

Seen about 5,700 times in the last 30 days, started from before the log-retention drop off. They are all from either ApiOptions or SpecialPreferences.

The stack traces look identical and originate from the same kind of method call, so tracking this as one issue for now rather than two.

Event Timeline

At least the API bit resembles T214963: Database contention due to concurrent requests to ApiOptions, where I've done a bit more research on the current situation.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:08 PM

And this is still happening very regularly and with increasing frequency in April of 2021

What's interesting to me is that the errors all appear to be coming from commonswiki.

I would assume this is fixed after the work on T278650
Are there still issues in the logs?