Page MenuHomePhabricator

Error 1264: Out of range value for column 'pp_page' at row 1
Closed, ResolvedPublicBUG REPORT

Description

Setup

  • MediaWiki | 1.39.7 (64425c7)16:12, 15 May 2024
  • PHP | 7.4.33 (apache2handler)
  • MariaDB | 10.5.23-MariaDB-0+deb11u1

Issue
When running "update.php" for the direct upgrade from MW 1.35.x to 1.39.x I got the following error:

Modifying pp_page field of table page_props...Wikimedia\Rdbms\DBQueryError from line 1618 of /../w/includes/libs/rdbms/database/Database.php: Error 1264: Out of range value for column 'pp_page' at row 1
Function: Wikimedia\Rdbms\Database::sourceFile( /../w/maintenance/archives/patch-page_props-pp_page.sql )
Query: ALTER TABLE  `02100_page_props`
 CHANGE  pp_page pp_page INT UNSIGNED NOT NULL

Backtrace

#0 /../w/includes/libs/rdbms/database/Database.php(1602): Wikimedia\Rdbms\Database->getQueryException()
#1 /../w/includes/libs/rdbms/database/Database.php(1576): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /../w/includes/libs/rdbms/database/Database.php(952): Wikimedia\Rdbms\Database->reportQueryError()
#3 /../w/includes/libs/rdbms/database/Database.php(3302): Wikimedia\Rdbms\Database->query()
#4 /../w/includes/libs/rdbms/database/Database.php(3241): Wikimedia\Rdbms\Database->sourceStream()
#5 /../w/includes/libs/rdbms/database/DBConnRef.php(103): Wikimedia\Rdbms\Database->sourceFile()
#6 /../w/includes/libs/rdbms/database/DBConnRef.php(807): Wikimedia\Rdbms\DBConnRef->__call()
#7 /../w/includes/installer/DatabaseUpdater.php(718): Wikimedia\Rdbms\DBConnRef->sourceFile()
#8 /../w/includes/installer/DatabaseUpdater.php(1000): DatabaseUpdater->applyPatch()
#9 /../w/includes/installer/DatabaseUpdater.php(547): DatabaseUpdater->modifyField()
#10 /../w/includes/installer/DatabaseUpdater.php(511): DatabaseUpdater->runUpdates()
#11 /../w/maintenance/update.php(209): DatabaseUpdater->doUpdates()
#12 /../w/maintenance/includes/MaintenanceRunner.php(309): UpdateMediaWiki->execute()
#13 /../w/maintenance/doMaintenance.php(85): MediaWiki\Maintenance\MaintenanceRunner->run()
#14 /../w/maintenance/update.php(319): require_once('/var/www/html/s...')
#15 {main}

Further info
Query:

SELECT MAX(pp_page) AS max_pp_page, MIN(pp_page) AS min_pp_page FROM `02100_page_props`;

Result:

+-------------+-------------+
| max_pp_page | min_pp_page |
+-------------+-------------+
|       16459 |         -42 |
+-------------+-------------+
1 row in set (0,000 sec)

Mitigation

Query:

UPDATE `02100_page_props` SET pp_page = 0 WHERE pp_page < 0;

Result:

Query OK, 1 row affected (0,001 sec)
Rows matched: 1  Changed: 1  Warnings: 0

followed by the query that initially failed (w/maintenance/archives/patch-page_props-pp_page.sql):
Query:

ALTER TABLE `02100_page_props` CHANGE `pp_page` `pp_page` INT UNSIGNED NOT NULL;

Result:

Query OK, 13107 rows affected (0,198 sec)              
Records: 13107  Duplicates: 0  Warnings: 0

After that, I was able to continue with "update.php." I am unsure where this issue may have originated and whether my way of mitigating it is recommended. Anyhow, now on MW 1.39.x, the wiki appears to be running without issues, at least none have been detected yet.

This issue was mentioned and is referenced on MediaWiki.org - Support desk.

Event Timeline

Kghbln updated the task description. (Show Details)

You had a page property for a page that had a negative page id ? That seems really unusual.

Well, what I reported is what I got. I'm not sure how this can happen, either, but it appears to be like this.

If you give an invalid title to the api in query... then the pagid you get back for the title in that query is negative (because everything in the result needs a key, even if it is invalid page). If then some sort of follow up action, takes that reply and processes it 'incorrectly' and you had the old 'incorrect' database schema... then i guess there is a chance of that ending up in the database somehow.

But i have no idea how to figure out if that was something old in mediawiki, an extension, maintenance script or some sort of javascript error.

It will probably remain a mystery. The wiki uses a lot of extensions. Thus, it may well be that the issue is to find somewhere here.

I get that there is not much that core MediaWiki can do here. It would be cool if someone could assess whether the way to mitigate the issue was okay. After that, we can close this issue. I mainly created it for this reason and for future reference if someone else runs into it.

I guess i would check if the page table has any pages with a negative id. If not i would just delete the negative entries from page_props. Afterall it should be impossible to ever match the negative entries.

You could also run refreshLinks.php --dfn-only which would probably fix up the page_props table.

Kghbln claimed this task.

I guess i would check if the page table has any pages with a negative id. If not i would just delete the negative entries from page_props. Afterall it should be impossible to ever match the negative entries.

I believe my way to mitigate the issue, as stated in the issue description, should do the job then.

You could also run refreshLinks.php --dfn-only which would probably fix up the page_props table.

Good pointer. This should be tried before fiddling with the data in the database itself.

I will now resolve the issue since enough information is available to get around this issue.