Page MenuHomePhabricator

"Duplicate entry 'XXX-YYY' for key 'itr_itemid_id_revision_id'" in "INSERT INTO `discussiontools_item_revisions`"
Open, Needs TriagePublic

Description

(The latest deployment of DiscussionTools permalinks backend to group1 wikis T315353#8392662 has resulted in some new errors, although a lot less numerous this time. It really is a gift that keeps on giving.)

There are a few occurrences of "Duplicate entry 'XXX-YYY' for key 'itr_itemid_id_revision_id'" (where "XXX" and "YYY" are different numbers).

https://logstash.wikimedia.org/goto/fc6ea240e98b381db12b9d275915e001

image.png (523×2 px, 52 KB)

Error
Error 1062: Duplicate entry 'XXX-YYY' for key 'itr_itemid_id_revision_id'
Function: MediaWiki\Extension\DiscussionTools\ThreadItemStore::insertThreadItems
Query: INSERT INTO `discussiontools_item_revisions` (itr_itemid_id,itr_revision_id,itr_items_id,itr_parent_id,itr_transcludedfrom,itr_level) VALUES ('XXX',YYY,'ZZZ','AAA',NULL,2)
exception.trace
…
#4 /srv/mediawiki/php-1.40.0-wmf.17/extensions/DiscussionTools/includes/ThreadItemStore.php(555): Wikimedia\Rdbms\Database->insert(string, array, string)
#5 /srv/mediawiki/php-1.40.0-wmf.17/includes/libs/rdbms/database/Database.php(2620): MediaWiki\Extension\DiscussionTools\ThreadItemStore->MediaWiki\Extension\DiscussionTools\{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#6 /srv/mediawiki/php-1.40.0-wmf.17/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure, string)
#7 /srv/mediawiki/php-1.40.0-wmf.17/includes/libs/rdbms/database/DBConnRef.php(680): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#8 /srv/mediawiki/php-1.40.0-wmf.17/extensions/DiscussionTools/includes/ThreadItemStore.php(566): Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure, string)
#9 /srv/mediawiki/php-1.40.0-wmf.17/extensions/DiscussionTools/includes/Hooks/DataUpdatesHooks.php(47): MediaWiki\Extension\DiscussionTools\ThreadItemStore->insertThreadItems(MediaWiki\Revision\RevisionStoreRecord, MediaWiki\Extension\DiscussionTools\ContentThreadItemSet)
#10 /srv/mediawiki/php-1.40.0-wmf.17/includes/deferred/MWCallableUpdate.php(38): MediaWiki\Extension\DiscussionTools\Hooks\DataUpdatesHooks->MediaWiki\Extension\DiscussionTools\Hooks\{closure}()
#11 /srv/mediawiki/php-1.40.0-wmf.17/includes/deferred/DeferredUpdates.php(474): MWCallableUpdate->doUpdate()
#12 /srv/mediawiki/php-1.40.0-wmf.17/includes/deferred/RefreshSecondaryDataUpdate.php(103): DeferredUpdates::attemptUpdate(MWCallableUpdate, Wikimedia\Rdbms\LBFactoryMulti)
#13 /srv/mediawiki/php-1.40.0-wmf.17/includes/deferred/DeferredUpdates.php(474): RefreshSecondaryDataUpdate->doUpdate()
#14 /srv/mediawiki/php-1.40.0-wmf.17/includes/Storage/DerivedPageDataUpdater.php(1834): DeferredUpdates::attemptUpdate(RefreshSecondaryDataUpdate, Wikimedia\Rdbms\LBFactoryMulti)
#15 /srv/mediawiki/php-1.40.0-wmf.17/includes/page/WikiPage.php(2150): MediaWiki\Storage\DerivedPageDataUpdater->doSecondaryDataUpdates(array)
#16 /srv/mediawiki/php-1.40.0-wmf.17/includes/jobqueue/jobs/RefreshLinksJob.php(243): WikiPage->doSecondaryDataUpdates(array)
#17 /srv/mediawiki/php-1.40.0-wmf.17/includes/jobqueue/jobs/RefreshLinksJob.php(152): RefreshLinksJob->runForTitle(Title)
#18 /srv/mediawiki/php-1.40.0-wmf.17/extensions/EventBus/includes/JobExecutor.php(79): RefreshLinksJob->run()
#19 /srv/mediawiki/rpc/RunSingleJob.php(77): MediaWiki\Extension\EventBus\JobExecutor->execute(array)
#20 {main}

It looks like the revisions are being processed simultaneously by multiple jobs? (as Ladsgroup was guessing in T322701#8382329)

I don't know if we can dig into that, but if that's the case, this should be harmless from our perspective – we should avoid logging errors about it when it happens, though…

(This is distinct from T323079: "Duplicate entry '0-XXX' for key 'itr_itemid_id_revision_id'" in "INSERT INTO `discussiontools_item_revisions`")

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
Opennayoub
OpenNone
OpenNone
Resolvedmatmarex
Openmatmarex
Openmatmarex
Resolvedmatmarex
Resolvedmatmarex
OpenNone

Event Timeline

Looking at an example of it for example https://logstash.wikimedia.org/app/discover#/doc/logstash-*/logstash-mediawiki-1-7.0.0-1-2022.11.15?id=R15SfIQBGZfvtWAWG4lG
The revision is quite old, there is no newer edit on the page so it is very likely caused by refreshlinks job being somehow trying to run the DT update twice (or the update itself is trying it twice).

I might be wrong but it feels like the last update in the transaction (starting line 526 on discussiontools_item_revisions) is suffering from REPEATABLE_READ issue as well?

ppelberg added a project: Editing-team.
ppelberg moved this task from Untriaged to Upcoming on the Editing-team board.

Noting that this and T323079: "Duplicate entry '0-XXX' for key 'itr_itemid_id_revision_id'" in "INSERT INTO `discussiontools_item_revisions`" are happening at what feels like a somewhat higher rate than the last few days. Checking logstash, that may not actually be the case, but they're persistent enough to stand out to deployers. (We've filtered them out of the mediawiki-new-errors dashboard in logstash, but they're something of an annoyance in logspam-watch.)