Page MenuHomePhabricator

Upgrading to 1.34: Key column 'Comment_Vote_Username' doesn't exist in table
Closed, ResolvedPublic

Description

Upgrading from 1.32 to 1.34, when running the update.php script, it ends with the following error:

Adding Comment_Vote_actor field to table Comments_Vote ...done.
Adding index Comments_Vote_actor_index to table Comments_Vote ...done.
Adding index Comment_Vote_actor to table Comments_Vote ...done.
Running .../extensions/Comments/includes/../sql/../maintenance/migrateOldCommentsVoteUserColumnsToActor.php...
done.
Table Comments_Vote contains Comment_Vote_user_id field. Dropping ...done.
Table Comments_Vote contains Comment_Vote_Username field. Dropping ...Wikimedia\Rdbms\DBQueryError from line 1603 of .../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? 
Query: ALTER TABLE `Comments_Vote` DROP COLUMN Comment_Vote_Username

Function: Wikimedia\Rdbms\Database::sourceFile( .../extensions/Comments/includes/../sql/patches/actor/drop-Comment_Vote_Username.sql )
Error: 1072 Key column 'Comment_Vote_Username' doesn't exist in table (192.168.56.1:3306)

#0 .../includes/libs/rdbms/database/Database.php(1574): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('Key column 'Com...', 1072, 'ALTER TABLE `Co...', 'Wikimedia\\Rdbms...')
#1 .../includes/libs/rdbms/database/Database.php(1152): Wikimedia\Rdbms\Database->reportQueryError('Key column 'Com...', 1072, 'ALTER TABLE `Co...', 'Wikimedia\\Rdbms...', false)
#2 .../includes/libs/rdbms/database/Database.php(4539): Wikimedia\Rdbms\Database->query('ALTER TABLE `Co...', 'Wikimedia\\Rdbms...')
#3 .../includes/libs/rdbms/database/Database.php(4474): Wikimedia\Rdbms\Database->sourceStream(Resource id #659, NULL, NULL, 'Wikimedia\\Rdbms...', NULL)
#4 .../includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->sourceFile('...')
#5 .../includes/libs/rdbms/database/MaintainableDBConnRef.php(35): Wikimedia\Rdbms\DBConnRef->__call('sourceFile', Array)
#6 .../includes/installer/DatabaseUpdater.php(691): Wikimedia\Rdbms\MaintainableDBConnRef->sourceFile('...')
#7 .../includes/installer/DatabaseUpdater.php(838): DatabaseUpdater->applyPatch('...', true, 'Table Comments_...')
#8 .../includes/installer/DatabaseUpdater.php(490): DatabaseUpdater->dropField('Comments_Vote', 'Comment_Vote_Us...', '...', true)
#9 .../includes/installer/DatabaseUpdater.php(458): DatabaseUpdater->runUpdates(Array, true)
#10 .../maintenance/update.php(205): DatabaseUpdater->doUpdates(Array)
#11 .../maintenance/doMaintenance.php(99): UpdateMediaWiki->execute()
#12 .../maintenance/update.php(277): require_once('...')
#13 {main}

The problem is in an index (Comments_Vote_user_id_index) that's using the field being removed.

Table structure before the update:

MariaDB> desc Comments_Vote;
+-----------------------+----------------+------+-----+---------------------+-------+
| Field                 | Type           | Null | Key | Default             | Extra |
+-----------------------+----------------+------+-----+---------------------+-------+
| Comment_Vote_ID       | int(11)        | NO   | PRI | 0                   |       |
| Comment_Vote_user_id  | int(11)        | NO   | MUL | 0                   |       |
| Comment_Vote_Username | varbinary(200) | NO   | PRI |                     |       |
| Comment_Vote_Score    | int(4)         | NO   | MUL | 0                   |       |
| Comment_Vote_Date     | datetime       | NO   |     | 0000-00-00 00:00:00 |       |
| Comment_Vote_IP       | varbinary(45)  | NO   |     |                     |       |
+-----------------------+----------------+------+-----+---------------------+-------+
6 rows in set (0.00 sec)

MariaDB> show index from Comments_Vote;
+---------------+------------+-----------------------------+--------------+-----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table         | Non_unique | Key_name                    | Seq_in_index | Column_name           | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------------+------------+-----------------------------+--------------+-----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Comments_Vote |          0 | Comments_Vote_user_id_index |            1 | Comment_Vote_ID       | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          0 | Comments_Vote_user_id_index |            2 | Comment_Vote_Username | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          1 | Comment_Vote_Score          |            1 | Comment_Vote_Score    | A         |           3 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          1 | Comment_Vote_user_id        |            1 | Comment_Vote_user_id  | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
+---------------+------------+-----------------------------+--------------+-----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
4 rows in set (0.01 sec)

Table structure after the (failed) update:

MariaDB> desc Comments_Vote;
+-----------------------+---------------------+------+-----+---------------------+-------+
| Field                 | Type                | Null | Key | Default             | Extra |
+-----------------------+---------------------+------+-----+---------------------+-------+
| Comment_Vote_ID       | int(11)             | NO   | PRI | 0                   |       |
| Comment_Vote_actor    | bigint(20) unsigned | NO   | MUL | NULL                |       |
| Comment_Vote_Username | varbinary(200)      | NO   | PRI |                     |       |
| Comment_Vote_Score    | int(4)              | NO   | MUL | 0                   |       |
| Comment_Vote_Date     | datetime            | NO   |     | 0000-00-00 00:00:00 |       |
| Comment_Vote_IP       | varbinary(45)       | NO   |     |                     |       |
+-----------------------+---------------------+------+-----+---------------------+-------+
6 rows in set (0,00 sec)

MariaDB> show index from Comments_Vote;
+---------------+------------+-----------------------------+--------------+-----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table         | Non_unique | Key_name                    | Seq_in_index | Column_name           | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------------+------------+-----------------------------+--------------+-----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Comments_Vote |          0 | Comments_Vote_user_id_index |            1 | Comment_Vote_ID       | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          0 | Comments_Vote_user_id_index |            2 | Comment_Vote_Username | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          0 | Comments_Vote_actor_index   |            1 | Comment_Vote_ID       | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          0 | Comments_Vote_actor_index   |            2 | Comment_Vote_actor    | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          1 | Comment_Vote_Score          |            1 | Comment_Vote_Score    | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| Comments_Vote |          1 | Comment_Vote_actor          |            1 | Comment_Vote_actor    | A         |           9 |     NULL | NULL   |      | BTREE      |         |               |
+---------------+------------+-----------------------------+--------------+-----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
6 rows in set (0,00 sec)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 595040 had a related patch set uploaded (by Martineznovo; owner: Martineznovo):
[mediawiki/extensions/Comments@master] Actor migration: Fix order of db patches. Drop index before column

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

Change 595040 merged by jenkins-bot:
[mediawiki/extensions/Comments@master] Actor migration: Fix order of db patches. Drop index before column

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