Page MenuHomePhabricator

OAuth throws "duplicate key" at some occasions
Open, LowPublic

Description

Error

Request ID: XWBpyQpAICAAAFBj-OgAAACC
Request URL: https://meta.m.wikimedia.org/wiki/Special:OAuth/authorize?oauth_token=(redacted)&oauth_consumer_key=e4813d75b345691996560c791d0640b0

message
MediaWiki\Extensions\OAuth\MWOAuthDAO::save	10.64.48.15	1062	Duplicate entry 'redacted' for key 'oaac_user_consumer_wiki' (10.64.48.15)	INSERT  INTO `oauth_accepted_consumer` (oaac_wiki,oaac_user_id,oaac_consumer_id,oaac_access_token,oaac_access_secret,oaac_grants,oaac_accepted) VALUES (redacted)
trace
#0 /srv/mediawiki/php-1.34.0-wmf.19/includes/libs/rdbms/database/Database.php(1564): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('Duplicate entry...', 1062, 'INSERT  INTO `o...', 'MediaWiki\\Exten...')
#1 /srv/mediawiki/php-1.34.0-wmf.19/includes/libs/rdbms/database/Database.php(1153): Wikimedia\Rdbms\Database->reportQueryError('Duplicate entry...', 1062, 'INSERT  INTO `o...', 'MediaWiki\\Exten...', false)
#2 /srv/mediawiki/php-1.34.0-wmf.19/includes/libs/rdbms/database/Database.php(2129): Wikimedia\Rdbms\Database->query('INSERT  INTO `o...', 'MediaWiki\\Exten...')
#3 /srv/mediawiki/php-1.34.0-wmf.19/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->insert('`oauth_accepted...', Array, 'MediaWiki\\Exten...')
#4 /srv/mediawiki/php-1.34.0-wmf.19/includes/libs/rdbms/database/DBConnRef.php(371): Wikimedia\Rdbms\DBConnRef->__call('insert', Array)
#5 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/backend/MWOAuthDAO.php(192): Wikimedia\Rdbms\DBConnRef->insert('oauth_accepted_...', Array, 'MediaWiki\\Exten...')
#6 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/backend/MWOAuthServer.php(409): MediaWiki\Extensions\OAuth\MWOAuthDAO->save(Object(Wikimedia\Rdbms\DBConnRef))
#7 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/control/MWOAuthConsumerAcceptanceSubmitControl.php(105): MediaWiki\Extensions\OAuth\MWOAuthServer->authorize('e4813d75b345691...', 'aaf17d381d62dab...', Object(User), false)
#8 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/control/MWOAuthSubmitControl.php(74): MediaWiki\Extensions\OAuth\MWOAuthConsumerAcceptanceSubmitControl->processAction('accept')
#9 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/frontend/specialpages/SpecialMWOAuth.php(424): MediaWiki\Extensions\OAuth\MWOAuthSubmitControl->submit()
#10 /srv/mediawiki/php-1.34.0-wmf.19/includes/htmlform/HTMLForm.php(689): MediaWiki\Extensions\OAuth\SpecialMWOAuth->MediaWiki\Extensions\OAuth\{closure}(Array, Object(HTMLForm))
#11 /srv/mediawiki/php-1.34.0-wmf.19/includes/htmlform/HTMLForm.php(581): HTMLForm->trySubmit()
#12 /srv/mediawiki/php-1.34.0-wmf.19/includes/htmlform/HTMLForm.php(596): HTMLForm->tryAuthorizedSubmit()
#13 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/frontend/specialpages/SpecialMWOAuth.php(482): HTMLForm->show()
#14 /srv/mediawiki/php-1.34.0-wmf.19/extensions/OAuth/includes/frontend/specialpages/SpecialMWOAuth.php(106): MediaWiki\Extensions\OAuth\SpecialMWOAuth->handleAuthorizationForm('aaf17d381d62dab...', 'e4813d75b345691...', false)
#15 /srv/mediawiki/php-1.34.0-wmf.19/includes/specialpage/SpecialPage.php(571): MediaWiki\Extensions\OAuth\SpecialMWOAuth->execute('authorize')
#16 /srv/mediawiki/php-1.34.0-wmf.19/includes/specialpage/SpecialPageFactory.php(582): SpecialPage->run('authorize')
#17 /srv/mediawiki/php-1.34.0-wmf.19/includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#18 /srv/mediawiki/php-1.34.0-wmf.19/includes/MediaWiki.php(892): MediaWiki->performRequest()
#19 /srv/mediawiki/php-1.34.0-wmf.19/includes/MediaWiki.php(523): MediaWiki->main()
#20 /srv/mediawiki/php-1.34.0-wmf.19/index.php(42): MediaWiki->run()
#21 /srv/mediawiki/w/index.php(3): require('/srv/mediawiki/...')
Impact

Unknown.

Notes

@Janbery encountered this error after logging to https://tools.wmflabs.org/ipcheck/. He was successful on second try.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFri, Aug 23, 10:41 PM
Tgr triaged this task as Low priority.Sun, Aug 25, 10:15 PM
Tgr added a subscriber: Tgr.

This would presumably happen due to replication lag (maybe when you double-submit, although in theory OAuth has a nonce to prevent that), since MWOAuthServer::getCurrentAuthorization uses the read connection. Should be pretty rare and at worst forces the user to repeat the authorization.

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