Upgrading 1.9.7 => 16.04.4 causes fatal DB error

Bug #1679699 reported by davosmith
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Won't Fix
Medium
Robert Lyon

Bug Description

Error:
[WAR] 75 (lib/dml.php:514) Failed to get a recordset: mysqli error: [1146: Table 'mahara_new.artefact_file_embedded' doesn't exist] in EXECUTE("SELECT "id" FROM "artefact_file_embedded" WHERE "fileid" = '11498' AND "resourcetype" = 'blogpost' AND "resourceid" = '11534' ")
[WAR] 75 (lib/dml.php:514) Command was: SELECT "id" FROM "artefact_file_embedded" WHERE "fileid" = ? AND "resourcetype" = ? AND "resourceid" = ? and values was (0:11498,1:blogpost,2:11534)
Call stack (most recent first):
  * get_recordset_sql(string(size 108), array(size 3)) at /var/www/html/mahara/lib/dml.php:825
  * get_field_sql(string(size 108), array(size 3)) at /var/www/html/mahara/lib/dml.php:813
  * get_field(string(size 22), string(size 2), string(size 6), string(size 5), string(size 12), string(size 8), string(size 10), string(size 5)) at /var/www/html/mahara/lib/embeddedimage.php:94
  * EmbeddedImage::prepare_embedded_images(string(size 624), string(size 8), string(size 5), null, string(size 3)) at /var/www/html/mahara/artefact/blog/db/upgrade.php:76
  * xmldb_artefact_blog_upgrade(string(size 10)) at /var/www/html/mahara/lib/upgrade.php:418
  * upgrade_plugin(object(stdClass)) at /var/www/html/mahara/lib/mahara.php:266
  * upgrade_mahara(array(size 1)) at /var/www/html/mahara/admin/cli/upgrade.php:53

The reason is that the artefact.blog upgrade for version 2015011501 assumes that the artefact.file upgrade for 2015111200 has already taken place and, hence, that the table 'artefact_file_embedded' has been created.

This is not the case for an upgrade from 1.9.7 to 16.04.4.

To work around this I've forced artefact.file to be the first artefact to be upgraded, by adding the following code to 'sort_upgrades':

    if ($weight1 == $weight2) {
        if ($k1 == 'artefact.file') {
            return -1;
        } else if ($k2 == 'artefact.file') {
            return 1;
        }
    }

This is a temporary change to make sure that the upgrade can be completed (which it has now done), but reporting here in the hope that this will save anyone else having similar problems.

Revision history for this message
Robert Lyon (robertl-9) wrote :

Hi davosmith,

I'm glad you were able to sort out your problem.

Upon looking at the code what would be useful is if we could pass in an overriding weight/dependency value based on what needs to be upgraded and from what version to what other version.

So that we could do the upgrades for things that add/edit/drop tables first before doing other upgrades.

I suspect this won't be an easy change - so for the interim I'll note here that upgrading from one major version to the next to the next should be fine to do

Cheers

Robert

Changed in mahara:
status: New → Confirmed
assignee: nobody → Robert Lyon (robertl-9)
importance: Undecided → Medium
milestone: none → 17.04.1
summary: - Upgradeing 1.9.7 => 16.04.4 causes fatal DB error
+ Upgrading 1.9.7 => 16.04.4 causes fatal DB error
Revision history for this message
Pat (pat-kira) wrote :
Download full text (4.0 KiB)

Robert,

I've also run into similar problem when upgrading from 1.6.10 to 17.04.2.

See one of the call stacks below (there are 3, please see attached for the whole thing)
--------------------------------------------------------------------------

Call stack (most recent first):
  * log_message("Array to string conversion", 8, true, true, "/vagrant/cqu-mahara/htdocs/lib/adodb/adodb-excepti...", 45) at /vagrant/cqu-mahara/htdocs/lib/errors.php:521
  * error(8, "Array to string conversion", "/vagrant/cqu-mahara/htdocs/lib/adodb/adodb-excepti...", 45, array(size 7)) at /vagrant/cqu-mahara/htdocs/lib/adodb/adodb-exceptions.inc.php:45
  * ADODB_Exception->__construct("postgres8", "adodb_throw", -18, "ERROR: relation "artefact_file_embedded" does not...", "SELECT * FROM "artefact_file_embedded" WHERE resou...", array(size 2), object(ADODB_postgres8)) at /vagrant/cqu-mahara/htdocs/lib/adodb/adodb-exceptions.inc.php:80
  * adodb_throw("postgres8", "adodb_throw", -18, "ERROR: relation "artefact_file_embedded" does not...", "SELECT * FROM "artefact_file_embedded" WHERE resou...", array(size 2), object(ADODB_postgres8)) at /vagrant/cqu-mahara/htdocs/lib/adodb/adodb.inc.php:313
  * ADODB_TransMonitor("postgres8", "EXECUTE", -18, "ERROR: relation "artefact_file_embedded" does not...", "SELECT * FROM "artefact_file_embedded" WHERE resou...", array(size 2), object(ADODB_postgres8)) at /vagrant/cqu-mahara/htdocs/lib/adodb/adodb.inc.php:1264
  * ADOConnection->_Execute("SELECT * FROM "artefact_file_embedded" WHERE resou...", array(size 2)) at /vagrant/cqu-mahara/htdocs/lib/adodb/adodb.inc.php:1224
  * ADOConnection->Execute("SELECT * FROM "artefact_file_embedded" WHERE resou...", array(size 2)) at /vagrant/cqu-mahara/htdocs/lib/dml.php:510
  * get_recordset_sql("SELECT * FROM "artefact_file_embedded" WHERE resou...", array(size 2)) at /vagrant/cqu-mahara/htdocs/lib/dml.php:466
  * get_recordset_select("artefact_file_embedded", "resourcetype = ? AND resourceid = ?", array(size 2), "", "*", "", "") at /vagrant/cqu-mahara/htdocs/lib/dml.php:666
  * get_records_select_array("artefact_file_embedded", "resourcetype = ? AND resourceid = ?", array(size 2)) at /vagrant/cqu-mahara/htdocs/lib/embeddedimage.php:196
  * EmbeddedImage::remove_embedded_images("wallpost", "815") at /vagrant/cqu-mahara/htdocs/lib/embeddedimage.php:69
  * EmbeddedImage::prepare_embedded_images("This document contains my three thinking pieces ht...", "wallpost", "815", null, "2301") at /vagrant/cqu-mahara/htdocs/blocktype/wall/db/upgrade.php:25
  * xmldb_blocktype_wall_upgrade("2009111200") at /vagrant/cqu-mahara/htdocs/lib/upgrade.php:423
  * upgrade_plugin(object(stdClass)) at /vagrant/cqu-mahara/htdocs/lib/db/upgrade.php:4231
  * xmldb_core_upgrade("2012080627") at /vagrant/cqu-mahara/htdocs/lib/upgrade.php:347
  * upgrade_core(object(stdClass)) at /vagrant/cqu-mahara/htdocs/lib/mahara.php:268
  * upgrade_mahara(array(size 1)) at /vagrant/cqu-mahara/htdocs/admin/cli/upgrade.php:53

----------------------------------------------------------------------------

From looking at the code, Ghada and I discovered that upgrade check of "2016012800" (in /htdocs/lib/db/upgrade.php, line 4228) was t...

Read more...

Revision history for this message
Pat (pat-kira) wrote :
Robert Lyon (robertl-9)
no longer affects: mahara/17.10
Changed in mahara:
milestone: 17.04.1 → 18.04.0
Revision history for this message
Robert Lyon (robertl-9) wrote :

It is now recommended to upgrade from 1.9.x => 15.04.0 and then upgrade again to versions higher than 15.04

Changed in mahara:
milestone: 18.04.0 → none
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.