Page MenuHomePhabricator

1.34.X update fails when ipblocks table is shared
Closed, ResolvedPublic

Description

Similar to T257356

I'm upgrading a wiki farm from 1.30.X to 1.34.X, and finding that a database patch introduced in the 1.34.X releases appears to break the update.

This occurs when upgrading from 1.33 or from 1.30.

I've narrowed it down to lines 11-14 in maintenance/archives/patch-drop-user-fields.sql

ALTER TABLE /*_*/ipblocks
  DROP COLUMN ipb_by,
  DROP COLUMN ipb_by_text,
  ALTER COLUMN ipb_by_actor DROP DEFAULT;

This doesn't appear to be performing a check to see if the table is shared, and is performed even when --doshared is not specified. It will run successfully for the first wiki to be upgraded, but all subsequent runs on wikis which share that table will fail with the MySQL error that column ipb_by does not exist.

Checking the ipblocks table local to the wiki reveals the ipb_by column is present, so perhaps this operation is supposed to run against the local table and is being inadvertantly run against the shared table.

It occurs whether the --doshared flag is specified or not.

I can resolve the error by running the update script once to perform the ALTER operation to the shared table, then commenting out the lines specified above for subsequent runs.

Event Timeline

Andru created this task.Jul 8 2020, 8:25 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 8 2020, 8:25 AM
Peachey88 updated the task description. (Show Details)Jul 8 2020, 8:29 AM
Reedy added a subscriber: Reedy.Jul 8 2020, 1:30 PM

The problem is the patch does the queries for many different tables, but only guard checks the logging table

			[ 'dropField', 'logging', 'log_user', 'patch-drop-user-fields.sql' ],

Inside dropField

	protected function dropField( $table, $field, $patch, $fullpath = false ) {
		if ( !$this->doTable( $table ) ) {
			return true;
		}

It calls doTable

		if ( in_array( $name, $wgSharedTables ) ) {
			$this->output( "...skipping update to shared table $name.\n" );
			return false;
		} else {
			return true;
		}

So as long as your $wgSharedTables is set right, this would work if the patch wasn't in one big combined file

Change 610290 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Split patch-drop-user-fields.sql into patch per table

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

Reedy added a comment.Jul 8 2020, 1:43 PM

Of course, in rMWc29909e59fd8: Mostly drop old pre-actor user schemas, sqlite was done file per table anyway :)

Reedy triaged this task as Medium priority.Jul 8 2020, 3:52 PM
Reedy added a project: MW-1.35-release.

Change 610097 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@REL1_34] Split patch-drop-user-fields.sql into patch per table

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

Change 610097 merged by jenkins-bot:
[mediawiki/core@REL1_34] Split patch-drop-user-fields.sql into patch per table

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

Change 610290 merged by jenkins-bot:
[mediawiki/core@master] Split patch-drop-user-fields.sql into patch per table

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

Reedy closed this task as Resolved.Jul 8 2020, 4:19 PM