Forums | Mahara Community

Support /
Upgrade fails (missing "artefact_attachment" table)


anonymous profile picture
Account deleted
Posts: 19

08 July 2011, 3:22

I am trying upgrade from 1.1.2 to adnother major version for example 1.2 or 1.4.

I have Postgre 8.4 with php 5.3.3 and Apache/2.2.16 (Debian).

The database prefix is "mahara_"

In minor upgrades like 1.1.2 to 1.1.3 everything ok, but in major upgrades I have the following error:

Could not execute command: ALTER TABLE "mahara_artefact_attachment" RENAME blogpost TO artefact; ALTER TABLE "mahara_artefact_attachment" RENAME file TO attachment; ALTER INDEX "mahara_arteblogblogfile_blofil_pk" RENAME TO "mahara_arteatta_artatt_pk"; ALTER INDEX "mahara_arteblogblogfile_blo_ix" RENAME TO "mahara_arteatta_art_ix"; ALTER INDEX "mahara_arteblogblogfile_fil_ix" RENAME TO "mahara_arteatta_att_ix"; ALTER TABLE "mahara_artefact_attachment" DROP CONSTRAINT "mahara_arteblogblogfile_blo_fk"; ALTER TABLE "mahara_artefact_attachment" ADD CONSTRAINT "mahara_arteatta_art_fk" FOREIGN KEY (artefact) REFERENCES "mahara_artefact"(id); ALTER TABLE "mahara_artefact_attachment" DROP CONSTRAINT "mahara_arteblogblogfile_fil_fk"; ALTER TABLE "mahara_artefact_attachment" ADD CONSTRAINT "mahara_arteatta_att_fk" FOREIGN KEY (attachment) REFERENCES "mahara_artefact"(id); 

Call stack (most recent first):
  • execute_sql(" ALTER TABLE {artefact_attachment} REN...") at/home/eportfolio/web/lib/db/upgrade.php:934
  • xmldb_core_upgrade("2009022606") at/home/eportfolio/web/lib/upgrade.php:301
  • upgrade_core(object(stdClass)) at/home/eportfolio/web/admin/upgrade.json.php:94

The problem as I realized that the artefact_attachment table is missing. If I'm correct it comes from artefact_blog_blogpost_file but at wich version? Is It OK at 1.1.2 that this change hasn't been done?

anonymous profile picture
Account deleted
Posts: 808

10 July 2011, 21:33

That's right, there should be a command directly before the one causing the error that renames the "mahara_artefact_blog_blogpost_file" table to "mahara_artefact_attachment".

Does your 1.1.2 database have mahara_artefact_blog_blogpost_file?

anonymous profile picture
Account deleted
Posts: 19
anonymous profile picture
Account deleted
Posts: 808

11 July 2011, 19:39

So the next thing I guess is to look and check that all those indexes that are being renamed exist in your db pre-upgrade.

I think there are other people who've had similar problems (search for "artefact_attachment" on this site).  There must have been some way (at one point) that those indexes got created without the expected names.  So I'd check for these:

arteblogblogfile_blofil_pk
arteblogblogfile_blo_ix
arteblogblogfile_fil_ix
arteblogblogfile_blo_fk
arteblogblogfile_fil_fk

They're expected in the upgrade, so if they don't exist, have a look at your db, and see if you can rename whatever primary keys, indexes, foreign keys exist on artefact_blog_blogpost_file to match those names.

Sorry about that.

anonymous profile picture
Account deleted
Posts: 19

12 July 2011, 2:53

I've already searched for "artefact_attachment", but I haven't got any relevant result but this:
http://mahara.org/interaction/forum/topic.php?id=1390

 

I have these indexes in artefact_blog_blogpost_file table:

 mahara_arteblogblogfile_blo_ix
 mahara_arteblogblogfile_blo_pk
 mahara_arteblogblogfile_fil_ix

With these definitions:

mahara_arteblogblogfile_blo_ix CREATE INDEX mahara_arteblogblogfile_blo_ix ON mahara_artefact_blog_blogpost_file USING btree (blogpost)
mahara_arteblogblogfile_blo_pk CREATE UNIQUE INDEX mahara_arteblogblogfile_blo_pk ON mahara_artefact_blog_blogpost_file USING btree (blogpost, file)
mahara_arteblogblogfile_fil_ix CREATE INDEX mahara_arteblogblogfile_fil_ix ON mahara_artefact_blog_blogpost_file USING btree (file)
anonymous profile picture
Account deleted
Posts: 808

12 July 2011, 17:29

Right, so your pk index has a different name that the one the upgrade is expecting (mahara_arteblogblogfile_blo_pk vs mahara_arteblogblogfile_blofil_pk).  Not sure why, but possibly it's been shortened because of the long prefix.

I'd try renaming mahara_arteblogblogfile_blo_pk to mahara_arteblogblogfile_blofil_pk, run the upgrade again and see if that works.

If it still fails, and if you're also missing the two foreign keys, try creating them with this:

ALTER TABLE mahara_artefact_blog_blogpost_file ADD CONSTRAINT mahara_arteblogblogfile_blo_fk FOREIGN KEY (blogpost) REFERENCES mahara_artefact (id);

ALTER TABLE mahara_artefact_blog_blogpost_file ADD CONSTRAINT mahara_arteblogblogfile_fil_fk FOREIGN KEY (file) REFERENCES mahara_artefact (id);

Then run the upgrade again.

anonymous profile picture
Account deleted
Posts: 19

14 July 2011, 2:43

I've renamed the mahara_arteblogblogfile_blo_pk to mahara_arteblogblogfile_blofil_pk but it still cannot upgrade. (upgrade fails without any error message)

The two Constraints are already exists, so i couldn't apply these commands.

anonymous profile picture
Account deleted
Posts: 808

14 July 2011, 17:13

Well, I'm afraid with no error message I've got nothing to go on :(

Is there anything in the webserver log?

You could try to drop the constraints first and then create them with those commands, but really I think if that were the problem you probably would have had an error message.

anonymous profile picture
Account deleted
Posts: 19

16 August 2011, 4:43

(Sorry for the late answer but I was on summer holiday, outside of the intranet.)

  1. I've started over again. (from 1.1.2)
  2. Renamed the mahara_arteblogblogfile_blo_pk to mahara_arteblogblogfile_blofil_pk 
  3. Then ran the upgrade. (to 1.4.0)
  4. I've got the Failed to upgrade! message at the 'core' line.

The apache error log contains this:

[Tue Aug 16 11:27:09 2011] [error] [client xx.xx.xx.xx] [INF] bf (lib/upgrade.php:1057) Enabled 3 HTML filters., referer: http://xx.xx.xx.xx/admin/upgrade.php

[Tue Aug 16 11:29:03 2011] [error] [client xx.xx.xx.xx]PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 7680 bytes) in /home/eportfolio/web/lib/dml.php(46) : runtime-created function on line 1, referer: http://xx.xx.xx.xx/admin/upgrade.php

The current memory limit is 512MB.

anonymous profile picture
Account deleted
Posts: 808

16 August 2011, 16:56

So you're past the artefact_attachment problem and you've hit a later upgrade which is consuming too much memory.  I guess you have quite a lot of data.  I'd try raising the memory limit temporarily, to what you can reasonably spare for the upgrade, and see if that gets you through.  Let me know how it goes.

If it still fails, plan B is to add some logging into htdocs/lib/db/upgrade.php to track down the upgrade that's using all the memory, and either rewrite it or just perform it manually.

14 results