Page MenuHomePhabricator

Error: 1406 Data too long for column 'site_global_key' (due to db names larger then the 32 limit)
Closed, ResolvedPublic

Description

When running a modified version of populateSitesTable.php (to fit our wikifarm), we got this error:

rhinos@jobrunner2:~$ sudo -u www-data php /srv/mediawiki/w/extensions/MirahezeMagic/maintenance/populateWikibaseSitesTable.php --wiki=datatrekwiki
Wikimedia\Rdbms\DBQueryError from line 1603 of /srv/mediawiki/w/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Function: DBSiteStore::saveSites
Error: 1406 Data too long for column 'site_global_key' at row 1 (db11.miraheze.org)

#0 /srv/mediawiki/w/includes/libs/rdbms/database/Database.php(1574): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('Data too long f...', 1406, 'INSERT  INTO `s...', 'DBSiteStore::sa...')
#1 /srv/mediawiki/w/includes/libs/rdbms/database/Database.php(1152): Wikimedia\Rdbms\Database->reportQueryError('Data too long f...', 1406, 'INSERT  INTO `s...', 'DBSiteStore::sa...', false)
#2 /srv/mediawiki/w/includes/libs/rdbms/database/Database.php(2140): Wikimedia\Rdbms\Database->query('INSERT  INTO `s...', 'DBSiteStore::sa...')
#3 /srv/mediawiki/w/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->insert('`sites`', Array, 'DBSiteStore::sa...')
#4 /srv/mediawiki/w/includes/libs/rdbms/database/DBConnRef.php(371): Wikimedia\Rdbms\DBConnRef->__call('insert', Array)
#5 /srv/mediawiki/w/includes/site/DBSiteStore.php(217): Wikimedia\Rdbms\DBConnRef->insert('sites', Array, 'DBSiteStore::sa...')
#6 /srv/mediawiki/w/includes/site/CachingSiteStore.php(162): DBSiteStore->saveSites(Array)
#7 /srv/mediawiki/w/extensions/Wikibase/lib/includes/Sites/SitesBuilder.php(62): CachingSiteStore->saveSites(Array)
#8 /srv/mediawiki/w/extensions/MirahezeMagic/maintenance/populateWikibaseSitesTable.php(56): Wikibase\Lib\Sites\SitesBuilder->buildStore(Array, 'wikipedia', 'datatrekwiki')
#9 /srv/mediawiki/w/maintenance/doMaintenance.php(99): PopulateWikibaseSitesTable->execute()
#10 /srv/mediawiki/w/extensions/MirahezeMagic/maintenance/populateWikibaseSitesTable.php(158): require_once('/srv/mediawiki/...')
#11 {main}
[222af3ff62544b0a2b96b5a9] [no req]   Wikimedia\Rdbms\DBTransactionError from line 1438 of /srv/mediawiki/w/includes/libs/rdbms/database/Database.php: Explicit transaction still active. A caller may have caught an error. Open transactions: DBSiteStore::saveSites
Backtrace:
#0 /srv/mediawiki/w/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1602): Wikimedia\Rdbms\Database->assertNoOpenTransactions()
#1 /srv/mediawiki/w/includes/libs/rdbms/loadbalancer/LoadBalancer.php(2109): Wikimedia\Rdbms\LoadBalancer->Wikimedia\Rdbms\{closure}(Wikimedia\Rdbms\DatabaseMysqli)
#2 /srv/mediawiki/w/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1621): Wikimedia\Rdbms\LoadBalancer->forEachOpenMasterConnection(Closure)
#3 /srv/mediawiki/w/includes/libs/rdbms/lbfactory/LBFactory.php(208): Wikimedia\Rdbms\LoadBalancer->approveMasterChanges(array, string, integer)
#4 /srv/mediawiki/w/includes/libs/rdbms/lbfactory/LBFactoryMulti.php(241): Wikimedia\Rdbms\LBFactory->Wikimedia\Rdbms\{closure}(Wikimedia\Rdbms\LoadBalancer, string, array)
#5 /srv/mediawiki/w/includes/libs/rdbms/lbfactory/LBFactory.php(210): Wikimedia\Rdbms\LBFactoryMulti->forEachLB(Closure, array)
#6 /srv/mediawiki/w/includes/libs/rdbms/lbfactory/LBFactory.php(269): Wikimedia\Rdbms\LBFactory->forEachLBCallMethod(string, array)
#7 /srv/mediawiki/w/maintenance/doMaintenance.php(127): Wikimedia\Rdbms\LBFactory->commitMasterChanges(string)
#8 /srv/mediawiki/w/extensions/MirahezeMagic/maintenance/populateWikibaseSitesTable.php(158): require_once(string)
#9 {main}

This is because some of our wikis have larger db names then the limit (> 32). Increasing this to 64 should fix this (and follows the same fix we have done for Flow rEFLWa53ac135b3cb: Increase flow_ext_ref.ref_src_wiki varchar size to 64 and Echo rECHO374aeb5fa962: Increase "euw_wiki" VARCHAR length from 30 to 64).

This also makes it match the max db name length for mysql databases

Script: https://github.com/miraheze/MirahezeMagic/blob/master/maintenance/populateWikibaseSitesTable.php

Downstream: https://phabricator.miraheze.org/T6044

Event Timeline

Restricted Application added subscribers: RhinosF1, Reception123, Aklapper. · View Herald Transcript

Change 620044 had a related patch set uploaded (by Paladox; owner: Paladox):
[mediawiki/core@master] Increase "sites. site_global_key" to 64

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

Aklapper renamed this task from Error: 1406 Data too long for column 'site_global_key' to Error: 1406 Data too long for column 'site_global_key' (due to db names larger then the 32 limit).Aug 15 2020, 4:34 AM
Reedy updated the task description. (Show Details)

Change 620044 merged by jenkins-bot:
[mediawiki/core@master] Increase "sites.site_global_key" to varbinary(64)

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

Change 622214 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/core@REL1_35] Increase "sites.site_global_key" to varbinary(64)

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

Change 622214 merged by jenkins-bot:
[mediawiki/core@REL1_35] Increase "sites.site_global_key" to varbinary(64)

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

Reedy assigned this task to Paladox.

We should back port it to 1.34 too.