Page MenuHomePhabricator

patch-reference_wiki.sql patch does not handle database prefix
Closed, ResolvedPublic

Description

Adding ref_src_wiki field to table flow_wiki_ref ...[Tue Dec 15 07:50:24 2015] [hphp] [7762:7ff3e8919c80:0:000001] [] 
Fatal error: Uncaught exception 'DBQueryError' with message 'A database error has occurred. Did you forget to run maintenance/update.php after upgrading?  See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script
Query: UPDATE `bw_flow_wiki_ref`, `bw_flow_workflow`
 SET flow_wiki_ref.ref_src_wiki = flow_workflow.workflow_wiki
 WHERE
 flow_wiki_ref.ref_src_workflow_id = flow_workflow.workflow_id

Function: DatabaseBase::sourceFile( /www/dev.translatewiki.net/docroot/w/extensions/Flow/db_patches/patch-reference_wiki.sql )
Error: 1054 Unknown column 'flow_wiki_ref.ref_src_wiki' in 'field list' (127.0.0.1:3306)
' in /www/dev.translatewiki.net/docroot/w/includes/db/Database.php:1090
Stack trace:
#0 /www/dev.translatewiki.net/docroot/w/includes/db/Database.php(1047): DatabaseBase->reportQueryError()
#1 /www/dev.translatewiki.net/docroot/w/includes/db/Database.php(4021): DatabaseBase->query()
#2 /www/dev.translatewiki.net/docroot/w/includes/db/Database.php(3935): DatabaseBase->sourceStream()
#3 /www/dev.translatewiki.net/docroot/w/includes/installer/DatabaseUpdater.php(669): DatabaseBase->sourceFile()
#4 /www/dev.translatewiki.net/docroot/w/includes/installer/DatabaseUpdater.php(717): DatabaseUpdater->applyPatch()
#5 /www/dev.translatewiki.net/docroot/w/includes/installer/DatabaseUpdater.php(455): DatabaseUpdater->addField()
#6 /www/dev.translatewiki.net/docroot/w/includes/installer/DatabaseUpdater.php(420): DatabaseUpdater->runUpdates()
#7 /www/dev.translatewiki.net/docroot/w/maintenance/update.php(169): DatabaseUpdater->doUpdates()
#8 /www/dev.translatewiki.net/docroot/w/maintenance/doMaintenance.php(103): UpdateMediaWiki->execute()
#9 /www/dev.translatewiki.net/docroot/w/maintenance/update.php(214): include()
#10 {main}

Even more mysteriously on next run of update.php claims

...have ref_src_wiki field in flow_wiki_ref table.

which sounds like my wiki will be silently corrupted now.

Details

Related Gerrit Patches:
mediawiki/extensions/Flow : masterFix patch-reference_wiki.sql index creation
mediawiki/extensions/Flow : masterMake patch-reference_wiki*.sql work with prefixed tables

Event Timeline

Nikerabbit raised the priority of this task from to Needs Triage.
Nikerabbit updated the task description. (Show Details)
Nikerabbit added a subscriber: Nikerabbit.
Restricted Application added a project: Collaboration-Team-Triage. · View Herald TranscriptDec 15 2015, 6:57 AM
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald Transcript

Change 259234 had a related patch set uploaded (by Matthias Mullie):
Make patch-reference_wiki*.sql work with prefixed tables

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

New patch waiting in gerrit.

Looking at the db patch, all you'll have to do to uncorrupt your wiki is remove column ref_src_wiki.flow_wiki_ref, then run the script again (once merged)

Change 259234 merged by jenkins-bot:
Make patch-reference_wiki*.sql work with prefixed tables

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

Catrope closed this task as Resolved.Dec 16 2015, 2:04 AM

New error introduced in the patch:

A database query error has occurred.
Query: DROP INDEX IF EXISTS flow_wiki_ref_idx ON `bw_flow_wiki_ref`
Error: 1064 You have an error in your SQL syntax
Nemo_bis reopened this task as Open.EditedDec 16 2015, 8:54 AM
Nemo_bis added a subscriber: Nemo_bis.

http://www.postgresql.org/docs/current/static/sql-dropindex.html:

DROP INDEX is a PostgreSQL language extension. There are no provisions for indexes in the SQL standard.

https://mariadb.com/kb/en/mariadb/drop-index/:

The IF EXISTS clause was added in MariaDB 10.1.4

+ https://bugs.mysql.com/bug.php?id=23543
Can we use a more standard way?

Change 259477 had a related patch set uploaded (by Matthias Mullie):
Fix patch-reference_wiki.sql index creation

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

We don't really need the IF EXISTS. I just added it to make it easier to uncorrupt your setup after having run the failing DB patch.
I've submitted a patch that just gets rid of the IF EXISTS. To uncorrupt your DB, guess you'll just have to recreate the first 2 indices so this DB patch doesn't fail over them not existing :)

Change 259477 merged by jenkins-bot:
Fix patch-reference_wiki.sql index creation

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

Catrope closed this task as Resolved.Dec 17 2015, 6:49 PM
Catrope added a subscriber: Catrope.