Page MenuHomePhabricator

Error running update.php in Modifying exptime field of table objectcache
Closed, ResolvedPublic

Description

I'm currently getting this error when running the maintenance/update.php script on my local MW installation.

Modifying exptime field of table objectcache ...Wikimedia\Rdbms\DBQueryError from line 1702 of /var/www/mediawiki/includes/libs/rdbms/database/Database.php: Error 1406: Data too long for column 'exptime' at row 1 (localhost)
Function: Wikimedia\Rdbms\Database::sourceFile( /var/www/mediawiki/maintenance/archives/patch-objectcache-exptime-notnull.sql )
Query: ALTER TABLE `objectcache`
 MODIFY exptime BINARY(14) NOT NULL


#0 /var/www/mediawiki/includes/libs/rdbms/database/Database.php(1686): Wikimedia\Rdbms\Database->getQueryException('Data too long f...', 1406, 'ALTER TABLE `ob...', 'Wikimedia\\Rdbms...')
#1 /var/www/mediawiki/includes/libs/rdbms/database/Database.php(1661): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('Data too long f...', 1406, 'ALTER TABLE `ob...', 'Wikimedia\\Rdbms...')
#2 /var/www/mediawiki/includes/libs/rdbms/database/Database.php(1230): Wikimedia\Rdbms\Database->reportQueryError('Data too long f...', 1406, 'ALTER TABLE `ob...', 'Wikimedia\\Rdbms...', false)
#3 /var/www/mediawiki/includes/libs/rdbms/database/Database.php(5125): Wikimedia\Rdbms\Database->query('ALTER TABLE `ob...', 'Wikimedia\\Rdbms...')
#4 /var/www/mediawiki/includes/libs/rdbms/database/Database.php(5060): Wikimedia\Rdbms\Database->sourceStream(Resource id #858, NULL, NULL, 'Wikimedia\\Rdbms...', NULL)
#5 /var/www/mediawiki/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->sourceFile('/var/www/mediaw...')
#6 /var/www/mediawiki/includes/libs/rdbms/database/MaintainableDBConnRef.php(35): Wikimedia\Rdbms\DBConnRef->__call('sourceFile', Array)
#7 /var/www/mediawiki/includes/installer/DatabaseUpdater.php(701): Wikimedia\Rdbms\MaintainableDBConnRef->sourceFile('/var/www/mediaw...')
#8 /var/www/mediawiki/includes/installer/DatabaseUpdater.php(1016): DatabaseUpdater->applyPatch('/var/www/mediaw...', false, 'Modifying expti...')
#9 /var/www/mediawiki/includes/installer/DatabaseUpdater.php(532): DatabaseUpdater->modifyField('objectcache', 'exptime', 'patch-objectcac...')
#10 /var/www/mediawiki/includes/installer/DatabaseUpdater.php(496): DatabaseUpdater->runUpdates(Array, false)
#11 /var/www/mediawiki/maintenance/update.php(182): DatabaseUpdater->doUpdates(Array)
#12 /var/www/mediawiki/maintenance/doMaintenance.php(106): UpdateMediaWiki->execute()
#13 /var/www/mediawiki/maintenance/update.php(253): require_once('/var/www/mediaw...')
#14 {main}
$ php --version
PHP 7.3.26-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jan 13 2021 08:00:44) ( NTS )
$ mysqld --version
mysqld  Ver 5.7.32-0ubuntu0.18.04.1 for Linux on x86_64 ((Ubuntu))

Event Timeline

Nikerabbit triaged this task as Unbreak Now! priority.Jan 27 2021, 2:42 PM
Nikerabbit added subscribers: Ladsgroup, Ammarpad, Nikerabbit.

I believe this is caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/636049 (rMW20d1849b53f3: Migrate objectcache to abstract schema).

This also blocks translatewiki.net deployment. Being very bold and marking as UBN! because this prevents us from testing stuff.

This is how our data looks currently:

MariaDB [translatewiki_net]> select exptime from bw_objectcache limit 1;
+---------------------+
| exptime             |
+---------------------+
| 2021-01-27 11:19:12 |
+---------------------+
1 row in set (0.000 sec)

hmm, it should truncate the table first before running the alter table. We can add the truncate to the .sql file itself. Would that work for you @Ammarpad ?

Change 659006 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/core@master] Truncate objectcache before changing exxptime field

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

Can you try it with this patch and let me know if it works? ^

Sorry, we thought T271062: Force truncation of objectcache table during database schema update would cover it, but of course we forget the truncation will come after applying the update. Truncating the table before the update will fix the issue, and we can safely do that since T271062 is approved, meaning the table will be truncated anyway before the update completes.

Can you try it with this patch and let me know if it works? ^

Works for me.

Can you try it with this patch and let me know if it works? ^

Sorry, we aborted the deployment and are planning to do this tomorrow.

Ammarpad lowered the priority of this task from Unbreak Now! to Medium.Jan 28 2021, 4:43 AM

Change 659006 merged by jenkins-bot:
[mediawiki/core@master] Truncate objectcache before changing exptime field

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

Ammarpad assigned this task to Ladsgroup.