Page MenuHomePhabricator

Special:Undelete: Wikimedia\Rdbms\DBQueryError: Error 1062: Duplicate entry for key 'PRIMARY' ...
Open, Needs TriagePublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Rdbms\DBQueryError: Error 1062: Duplicate entry '1007398126' for key 'PRIMARY' (db1163)
Function: MediaWiki\Revision\RevisionStore::insertRevisionRowOn
Query: INSERT INTO `revision` (rev_page,rev_parent_id,rev_minor_e
exception.trace
from /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(1809)
#0 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(1793): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(1768): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(1327): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(2540): Wikimedia\Rdbms\Database->query(string, string, integer)
#4 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(2520): Wikimedia\Rdbms\Database->doInsert(string, array, string)
#5 /srv/mediawiki/php-1.38.0-wmf.2/includes/Revision/RevisionStore.php(787): Wikimedia\Rdbms\Database->insert(string, array, string)
#6 /srv/mediawiki/php-1.38.0-wmf.2/includes/Revision/RevisionStore.php(638): MediaWiki\Revision\RevisionStore->insertRevisionRowOn(Wikimedia\Rdbms\DatabaseMysqli, MediaWiki\Revision\RevisionArchiveRecord, integer)
#7 /srv/mediawiki/php-1.38.0-wmf.2/includes/Revision/RevisionStore.php(492): MediaWiki\Revision\RevisionStore->insertRevisionInternal(MediaWiki\Revision\RevisionArchiveRecord, Wikimedia\Rdbms\DatabaseMysqli, MediaWiki\User\UserIdentityValue, CommentStoreComment, WikiPage, integer, integer)
#8 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/Database.php(4782): MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#9 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#10 /srv/mediawiki/php-1.38.0-wmf.2/includes/libs/rdbms/database/DBConnRef.php(668): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#11 /srv/mediawiki/php-1.38.0-wmf.2/includes/Revision/RevisionStore.php(494): Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure)
#12 /srv/mediawiki/php-1.38.0-wmf.2/includes/page/UndeletePage.php(398): MediaWiki\Revision\RevisionStore->insertRevisionOn(MediaWiki\Revision\RevisionArchiveRecord, Wikimedia\Rdbms\DBConnRef)
#13 /srv/mediawiki/php-1.38.0-wmf.2/includes/page/UndeletePage.php(155): MediaWiki\Page\UndeletePage->undeleteRevisions(array, boolean, string)
#14 /srv/mediawiki/php-1.38.0-wmf.2/includes/page/PageArchive.php(414): MediaWiki\Page\UndeletePage->undelete(array, string, array, boolean, NULL)
#15 /srv/mediawiki/php-1.38.0-wmf.2/includes/specials/SpecialUndelete.php(1358): PageArchive->undeleteAsUser(array, User, string, array, boolean)
#16 /srv/mediawiki/php-1.38.0-wmf.2/includes/specials/SpecialUndelete.php(324): SpecialUndelete->undelete()
#17 /srv/mediawiki/php-1.38.0-wmf.2/includes/specialpage/SpecialPage.php(647): SpecialUndelete->execute(NULL)
#18 /srv/mediawiki/php-1.38.0-wmf.2/includes/specialpage/SpecialPageFactory.php(1371): SpecialPage->run(NULL)
#19 /srv/mediawiki/php-1.38.0-wmf.2/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#20 /srv/mediawiki/php-1.38.0-wmf.2/includes/MediaWiki.php(925): MediaWiki->performRequest()
#21 /srv/mediawiki/php-1.38.0-wmf.2/includes/MediaWiki.php(559): MediaWiki->main()
#22 /srv/mediawiki/php-1.38.0-wmf.2/index.php(53): MediaWiki->run()
#23 /srv/mediawiki/php-1.38.0-wmf.2/index.php(46): wfIndexMain()
#24 /srv/mediawiki/w/index.php(3): require(string)
#25 {main}
Impact

A single instance of this in 1.38.0-wmf.2.

Notes

Feels like a duplicate action possibly taken either by the same user or by multiple users.

Should be caught and presented to user in a useful fashion, assuming that's the case.

Details

Request URL
https://en.wikipedia.org/w/index.php?title=*&action=submit

Event Timeline

Probably related to recent refactoring by @Daimona.

Probably related to recent refactoring by @Daimona.

I don't think so: the only patches included in wmf.2 are r715565, r715567 and r715578, none of which changes any backend logic, and all of them are backwards-compatible. Moreover, I can see that similar errors were already happening before the refactoring: I can find 7 of them in the last 3 months, for instance this one was in July:

Error 1062: Duplicate entry '1662247' for key 'PRIMARY' (db2105)
Function: MediaWiki\Revision\RevisionStore::insertRevisionRowOn
Query: INSERT INTO `revision` (rev_page,rev_parent_id,rev_minor_edit,rev_timestamp,rev_deleted,rev_len,rev_sha1,rev_id) VALUES ( ...
from /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(1760)
#0 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(1744): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(1719): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(1283): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(2406): Wikimedia\Rdbms\Database->query(string, string, integer)
#4 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(2386): Wikimedia\Rdbms\Database->doInsert(string, array, string)
#5 /srv/mediawiki/php-1.37.0-wmf.15/includes/Revision/RevisionStore.php(782): Wikimedia\Rdbms\Database->insert(string, array, string)
#6 /srv/mediawiki/php-1.37.0-wmf.15/includes/Revision/RevisionStore.php(633): MediaWiki\Revision\RevisionStore->insertRevisionRowOn(Wikimedia\Rdbms\DatabaseMysqli, MediaWiki\Revision\RevisionArchiveRecord, integer)
#7 /srv/mediawiki/php-1.37.0-wmf.15/includes/Revision/RevisionStore.php(487): MediaWiki\Revision\RevisionStore->insertRevisionInternal(MediaWiki\Revision\RevisionArchiveRecord, Wikimedia\Rdbms\DatabaseMysqli, MediaWiki\User\UserIdentityValue, CommentStoreComment, Title, integer, integer)
#8 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/Database.php(4656): MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#9 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#10 /srv/mediawiki/php-1.37.0-wmf.15/includes/libs/rdbms/database/DBConnRef.php(649): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#11 /srv/mediawiki/php-1.37.0-wmf.15/includes/Revision/RevisionStore.php(489): Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure)
#12 /srv/mediawiki/php-1.37.0-wmf.15/includes/page/PageArchive.php(737): MediaWiki\Revision\RevisionStore->insertRevisionOn(MediaWiki\Revision\RevisionArchiveRecord, Wikimedia\Rdbms\DBConnRef)
#13 /srv/mediawiki/php-1.37.0-wmf.15/includes/page/PageArchive.php(486): PageArchive->undeleteRevisions(array, boolean, string)
#14 /srv/mediawiki/php-1.37.0-wmf.15/includes/specials/SpecialUndelete.php(1333): PageArchive->undeleteAsUser(array, User, string, array, boolean)
#15 /srv/mediawiki/php-1.37.0-wmf.15/includes/specials/SpecialUndelete.php(324): SpecialUndelete->undelete()
#16 /srv/mediawiki/php-1.37.0-wmf.15/includes/specialpage/SpecialPage.php(646): SpecialUndelete->execute(NULL)
#17 /srv/mediawiki/php-1.37.0-wmf.15/includes/specialpage/SpecialPageFactory.php(1363): SpecialPage->run(NULL)
#18 /srv/mediawiki/php-1.37.0-wmf.15/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#19 /srv/mediawiki/php-1.37.0-wmf.15/includes/MediaWiki.php(925): MediaWiki->performRequest()
#20 /srv/mediawiki/php-1.37.0-wmf.15/includes/MediaWiki.php(559): MediaWiki->main()
#21 /srv/mediawiki/php-1.37.0-wmf.15/index.php(53): MediaWiki->run()
#22 /srv/mediawiki/php-1.37.0-wmf.15/index.php(46): wfIndexMain()
#23 /srv/mediawiki/w/index.php(3): require(string)
#24 {main}

It's the same error AFAICS.

I haven't investigated why it happens, but my first thought would be a race condition (i.e. users A and B try to undelete a page at the same time, and one of the two requests already moved some rows from archive to revision).

Krinkle updated the task description. (Show Details)