Page MenuHomePhabricator

Duplicate entry error in LocalisationCache
Open, Needs TriagePublicBUG REPORT

Description

  • MediaWiki (master branch)
  • PHP 7.4.3
  • MariaDB 10.1.36

Steps to Reproduce:

# php maintenance/eval.php
> MediaWiki\MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage('mr')
> MediaWiki\MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage('pam')
> MediaWiki\MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage('sh')
> MediaWiki\MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage('tl')
> MediaWiki\MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage('tly')

Actual Results:

Error: 1062 Duplicate entry 'mr-messages:apihelp-query+allusers-example-y' for key 'PRIMARY' (localhost)

#0 ...\mediawiki\includes\libs\rdbms\database\Database.php(1663): Wikimedia\Rdbms\Database->getQueryException('Duplicate entry...', 1062, 'INSERT INTO `l1...', 'LCStoreDB::fini...')
#1 ...\mediawiki\includes\libs\rdbms\database\Database.php(1640): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('Duplicate entry...', 1062, 'INSERT INTO `l1...', 'LCStoreDB::fini...')
#2 ...\mediawiki\includes\libs\rdbms\database\Database.php(1215): Wikimedia\Rdbms\Database->reportQueryError('Duplicate entry...', 1062, 'INSERT INTO `l1...', 'LCStoreDB::fini...', false)
#3 ...\mediawiki\includes\libs\rdbms\database\Database.php(2302): Wikimedia\Rdbms\Database->query('INSERT INTO `l1...', 'LCStoreDB::fini...', 128)
#4 ...\mediawiki\includes\libs\rdbms\database\Database.php(2283): Wikimedia\Rdbms\Database->doInsert('l10n_cache', Array, 'LCStoreDB::fini...')
#5 ...\mediawiki\includes\libs\rdbms\database\DBConnRef.php(68): Wikimedia\Rdbms\Database->insert('l10n_cache', Array, 'LCStoreDB::fini...')
#6 ...\mediawiki\includes\libs\rdbms\database\DBConnRef.php(369): Wikimedia\Rdbms\DBConnRef->__call('insert', Array)
#7 ...\mediawiki\includes\cache\localisation\LCStoreDB.php(98): Wikimedia\Rdbms\DBConnRef->insert('l10n_cache', Array, 'LCStoreDB::fini...')
#8 ...\mediawiki\includes\cache\localisation\LocalisationCache.php(1044): LCStoreDB->finishWrite()
#9 ...\mediawiki\includes\cache\localisation\LocalisationCache.php(489): LocalisationCache->recache('mr')
#10 ...\mediawiki\includes\cache\localisation\LocalisationCache.php(363): LocalisationCache->initLanguage('mr')
#11 ...\mediawiki\includes\cache\localisation\LocalisationCache.php(304): LocalisationCache->loadItem('mr', 'fallbackSequenc...')
#12 ...\mediawiki\includes\language\LanguageFallback.php(106): LocalisationCache->getItem('mr', 'fallbackSequenc...')
#13 ...\mediawiki\includes\language\LanguageFactory.php(167): MediaWiki\Languages\LanguageFallback->getAll('mr')
#14 ...\mediawiki\includes\language\LanguageFactory.php(114): MediaWiki\Languages\LanguageFactory->newFromCode('mr')
#15 ...\mediawiki\maintenance\eval.php(78) : eval()'d code(1): MediaWiki\Languages\LanguageFactory->getLanguage('mr')
#16 ...\mediawiki\maintenance\eval.php(78): eval()
#17 {main}

Expected Results:
Empty result and no error.

Event Timeline

getLanguageFactory was introduced in MediaWiki 1.35.0-wmf.4

We're catching this error when running MW 1.35.2 and the rebuildLocalisationCache.php script.

...
Rebuilding mnw...
Rebuilding mo...
Rebuilding mr...
Wikimedia\Rdbms\DBQueryError from line 1699 of /var/www/html/w/includes/libs/rdbms/database/Database.php: Error 1062: Duplicate entry 'mr-messages:apihelp-query+allusers-example-y' for key 'wikicryptopp_l10n_cache.PRIMARY' (localhost)
Function: LCStoreDB::finishWrite
Query: INSERT INTO `wikicryptopp_l10n_cache` (lc_lang,lc_key,lc_value) VALUES ('mr','messages:apihelp-query+allcategories-param-min','s:55:\"Only return categories with at least this many members.\";'),('mr','messages:apihelp-query+allcategories-param-max','s:54:\"Only return categories with at most this many members.\";'),('mr','messages:apihelp-query+allcategories-param-limit','s:30:\"How many categories to return.\";'),('mr','messages:apihelp-query+allcategories-param-prop','s:24:\"Which properties to get:\";'),('mr','messages:apihelp-query+allcategories-paramvalue-prop-size','s:37:\"Adds number of pages in the category.\";'),('mr','messages:apihelp-query+allcategories-paramvalue-prop-hidden','s:72:\"Tags categories that are hidden with <code>_&#95;HIDDENCAT_&#95;</code>.\";'),('mr','messages:apihelp-query+allcategories-example-size','s:64:\"List categories with information on the number of pages in each.\";'),('mr','messages:apihelp-query+allcategories-example-generator','s:86:\"Retrieve info about the category page itself for categories beginning <kbd>List</kbd>.\";'),('mr','messages:apihelp-query+alldeletedrevisions-summary','s:55:\"List all deleted revisions by a user or in a namespace.\";'),('mr','messages:apihelp-query+alldeletedrevisions-paraminfo-useronly','s:40:\"May only be used with <var>$3user</var>.\";'),('mr','messages:apihelp-query+alldeletedrevisions-paraminfo-nonuseronly','s:38:\"Cannot be used with <var>$3user</var>.\";')...
<hundreds of more lines omitted>