Page MenuHomePhabricator

Wikimedia\Rdbms\DBQueryError: Error 1062: Duplicate entry 'Botanik' for key 'pap_project_title' (db2107)Function: MediaWiki\Extension\PageAssessments\PageAssessmentsDAO::insertProjectQuery: INSERT INTO `page_assessments_projects` (pap_project_title,pap_project_id) VALUES ('Botanik',NULL)
Closed, ResolvedPublic1 Estimated Story PointsPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Rdbms\DBQueryError: Error 1062: Duplicate entry 'Botanik' for key 'pap_project_title' (db2107)
Function: MediaWiki\Extension\PageAssessments\PageAssessmentsDAO::insertProject
Query: INSERT INTO `page_assessments_proje
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/Database.php(1760)
#0 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/Database.php(1744): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/Database.php(1719): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/Database.php(1283): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/Database.php(2406): Wikimedia\Rdbms\Database->query(string, string, integer)
#4 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/Database.php(2386): Wikimedia\Rdbms\Database->doInsert(string, array, string)
#5 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->insert(string, array, string)
#6 /srv/mediawiki/php-1.37.0-wmf.12/includes/libs/rdbms/database/DBConnRef.php(373): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#7 /srv/mediawiki/php-1.37.0-wmf.12/extensions/PageAssessments/src/PageAssessmentsDAO.php(207): Wikimedia\Rdbms\DBConnRef->insert(string, array, string)
#8 /srv/mediawiki/php-1.37.0-wmf.12/extensions/PageAssessments/src/PageAssessmentsDAO.php(73): MediaWiki\Extension\PageAssessments\PageAssessmentsDAO::insertProject(string)
#9 /srv/mediawiki/php-1.37.0-wmf.12/extensions/PageAssessments/src/Hooks.php(73): MediaWiki\Extension\PageAssessments\PageAssessmentsDAO::doUpdates(Title, array, integer)
#10 /srv/mediawiki/php-1.37.0-wmf.12/includes/HookContainer/HookContainer.php(338): MediaWiki\Extension\PageAssessments\Hooks::onLinksUpdateComplete(LinksUpdate, integer)
#11 /srv/mediawiki/php-1.37.0-wmf.12/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#12 /srv/mediawiki/php-1.37.0-wmf.12/includes/HookContainer/HookRunner.php(2330): MediaWiki\HookContainer\HookContainer->run(string, array)
#13 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/LinksUpdate.php(214): MediaWiki\HookContainer\HookRunner->onLinksUpdateComplete(LinksUpdate, integer)
#14 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/AutoCommitUpdate.php(44): LinksUpdate->{closure}(Wikimedia\Rdbms\MaintainableDBConnRef, string)
#15 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdates.php(513): AutoCommitUpdate->doUpdate()
#16 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdates.php(390): DeferredUpdates::attemptUpdate(AutoCommitUpdate, Wikimedia\Rdbms\LBFactoryMulti)
#17 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdates.php(234): DeferredUpdates::run(AutoCommitUpdate, Wikimedia\Rdbms\LBFactoryMulti, Monolog\Logger, BufferingStatsdDataFactory, string)
#18 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdatesScope.php(267): DeferredUpdates::{closure}(AutoCommitUpdate, integer)
#19 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdatesScope.php(196): DeferredUpdatesScope->processStageQueue(integer, integer, Closure)
#20 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdates.php(237): DeferredUpdatesScope->processUpdates(integer, Closure)
#21 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdatesScope.php(264): DeferredUpdates::{closure}(RefreshSecondaryDataUpdate, integer)
#22 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdatesScope.php(196): DeferredUpdatesScope->processStageQueue(integer, integer, Closure)
#23 /srv/mediawiki/php-1.37.0-wmf.12/includes/deferred/DeferredUpdates.php(242): DeferredUpdatesScope->processUpdates(integer, Closure)
#24 /srv/mediawiki/php-1.37.0-wmf.12/includes/MediaWiki.php(1128): DeferredUpdates::doUpdates(string)
#25 /srv/mediawiki/php-1.37.0-wmf.12/includes/MediaWiki.php(838): MediaWiki->restInPeace()
#26 /srv/mediawiki/php-1.37.0-wmf.12/api.php(125): MediaWiki->doPostOutputShutdown()
#27 /srv/mediawiki/php-1.37.0-wmf.12/api.php(45): wfApiMain()
#28 /srv/mediawiki/w/api.php(3): require(string)
#29 {main}
Impact

TBD

Notes

Referer is https://tr.wikipedia.org/w/index.php?title=*&action=edit&redlink=1, so likely an ajax part of the extension connecting to its API and failing to do what it was meant to do.

Event Timeline

MusikAnimal added a subscriber: MusikAnimal.

The API is read-only, so that's not it. The INSERTs happen when a page is saved that uses the {{#assessment}} parser function, in this case https://tr.wikipedia.org/wiki/Tartışma:Janaki_Ammal.

My guess is here the user clicked "Publish changes" twice in very quick succession, such that when the second request happened it didn't know about the 'Botanik' project since it hadn't been replicated yet (PageAssessmentsDAO.php#L183), so it tried to INSERT it again. Given we already have a check to prevent duplicate projects from being inserted, I suppose the quick and simple solution here is to add an IGNORE when INSERTing, as we'd rather not change the fetching of project IDs to use DB_PRIMARY. We did the same thing when inserting individual assessments, too (T152080).

As a side note, while a WikiProject called 'Botanik' exists in the database, it doesn't seem to actually exist on the wiki, judging by the red links at https://tr.wikipedia.org/wiki/Tartışma:Janaki_Ammal. The editor probably introduced a typo or something.

Change 704832 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/PageAssessments@master] Use IGNORE to prevent duplicate entry errors when adding new projects

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

Change 704832 merged by jenkins-bot:

[mediawiki/extensions/PageAssessments@master] Use IGNORE to prevent duplicate entry errors when adding new projects

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

This will be pretty difficult if not impossible to QA. I'm not even sure PageAssessents is installed on the Beta cluster. At any rate, the patch should prevent this error from happening again and shouldn't have any side effects. I'll be bold and close this as resolved.