Page MenuHomePhabricator

Upgrade from 1.21 to 1.35 fails: patch-drop-image-user-fields.sql tries to drop img_user_timestamp which may not exist on some upgrades
Closed, ResolvedPublic

Description

Hi,
I have tried to upgrade the MW version from 1.21 to 1.35
The update (update.php) fails.
The error is in the script patch-drop-image-user-fields.sql

The script tries to replace an index with the name img_user_timestamp. But this is called img_actor_timestamp;

ALTER TABLE `image`
 DROP INDEX img_actor_timestamp,
 DROP INDEX img_usertext_timestamp,
 DROP COLUMN img_user,
 DROP COLUMN img_user_text,
  ALTER COLUMN img_actor DROP DEFAULT;

Event Timeline

Ozz renamed this task from Database Upgrade from 1.21 to 1.35 fails missing to Database Upgrade from 1.21 to 1.35 fails.Nov 9 2020, 11:49 AM
Aklapper renamed this task from Database Upgrade from 1.21 to 1.35 fails to Upgrade from 1.21 to 1.35 fails: patch-drop-image-user-fields.sql tries to drop img_user_timestamp instead of img_actor_timestamp.Nov 9 2020, 11:52 AM
Aklapper updated the task description. (Show Details)
Aklapper added a project: good first task.

Hi @Ozz, thanks for taking the time to report this and welcome to Wikimedia Phabricator!

Looks like a mistake from T188327.

Reedy added a subscriber: Reedy.

Well, yes and no.

If we look back at REL1_31 - https://github.com/wikimedia/mediawiki/blob/1.31.0/maintenance/tables.sql#L1177-L1179

CREATE INDEX /*i*/img_user_timestamp ON /*_*/image (img_user,img_timestamp);
CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
CREATE INDEX /*i*/img_actor_timestamp ON /*_*/image (img_actor,img_timestamp);

Both img_user_timestamp and img_actor_timestamp existed - It was added in rMW792555fceed9: Add image.img_user, image.img_timestamp index in MW 1.29.0

If we look at REL1_35 https://github.com/wikimedia/mediawiki/blob/1.35.0/maintenance/tables.sql#L1093, img_actor_timestamp still exists (img_user_timestamp doesn't), so it's not as simple as replacing the index being dropped; we don't want to drop img_actor_timestamp. We want to make the dropping of img_user_timestamp a bit more conditional, rather than guarded by whether image.img_user still exists

I'm guessing the patch to add img_user_timestamp was removed when the index was removed from the canonical schema, so it was never added, and is unconditionally removed, which breaks

This is one of the things that happens when people upgrade from pretty old versions in one go... Yes it should work, but occasionally it doesn't. We have a task about reducing that "upgrade windows", so you'd need to potentially go in intermediatary steps.

Reedy renamed this task from Upgrade from 1.21 to 1.35 fails: patch-drop-image-user-fields.sql tries to drop img_user_timestamp instead of img_actor_timestamp to Upgrade from 1.21 to 1.35 fails: patch-drop-image-user-fields.sql tries to drop img_user_timestamp which may not exist on some upgrades.Dec 7 2020, 3:22 AM
Reedy added a project: MW-1.35-release.

Do you have the full output of update.php?

I'm curious why it wasn't added by this guarded addIndex call...

			[ 'ifTableNotExists', 'actor',
				'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],

Change 646157 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Split dropping of image.img_user_timestamp

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

Change 646157 merged by jenkins-bot:
[mediawiki/core@master] Split dropping of image.img_user_timestamp

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

Change 647290 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@REL1_35] Split dropping of image.img_user_timestamp

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

Change 647290 merged by jenkins-bot:
[mediawiki/core@REL1_35] Split dropping of image.img_user_timestamp

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

Reedy claimed this task.