Trac on Dreamhost. A nightmare but maybe

Like many developers out there, I love trac. Because it’s not easy to setup or maintain, this love is a curse. Fortunately we’re in a bright spot at the moment, here’s how I got out of the rut…

Recently my trac installs for Mapufacture and worldKit have just not been working. At first, this looked to be due to a recent configuration change for FastCGI on Dreamhost, and I requested the fix but no go. Trac then started complaining about…

OperationalError: database is locked
args = ('database is locked',)

Trac usually uses sqlite, a single file SQL compliant db. If I tried to access it on the command line, I get a similar complaint about it being locked. Killed off the fcgi processes, waited .. nothing would help except for moving the db file off the file system and accessing it from /tmp, where it mysteriously unlocked. sqlite didn’t like something about Dreamhost’s nfs, and DH support, though helpful, couldn’t resolve it.

Reading up on trac, I found out there was beta support for MySQL db backend in 0.10.4. This sounded a lot more stable than sqlite actually. So I followed the instructions here to fresh install and create a trac project, with 0.10.4dev rather than 10.3. The instructions for configuring it with the mysql backend are here.

This left me with a working Trac, but none of the old tickets and pages. So I needed to get the content from the sqlite db into mysql. Now my prior version of Trac was 0.9, pre-mysql support, and some of the column names were valid under sqlite but not mysql .. like “change” and “sql”. The idea for switching to mysql would be to “upgrade” the db with trac-admin, then dump and upload sqlite into mysql. But since the sqlite db was locked when on the nfs, I couldn’t do that.

So first, from /tmp, I dumped the sqlite db into a file. I then manually applied the db migrations. Those could be found in lib/python2.3/site-packages/trac/upgrades/. Looking in the “system” table, the “database_version” number was set to “16”, so I manually applied 17-19, and then set the db version to “19” manually.

Also had to tweak the sqlite SQL. Table names for INSERTs were in quotes, which mysql doesn’t like, so removed those. In the table CREATEs, many TEXT columns had UNIQUE and PRIMARY assigned to them, which mysql again doesn’t like, so I removed those statements too. Finally, I had to manually add AUTO_INCREMENT to the primary keys on the “report” and “ticket” tables .. sqlite assumes that any integer primary key is auto incremented, but mysql needs to be told to.

It might not have been necessary to go through all that, the trac wiki suggests this conversion method and that might work too. In any case, trac is now almost working for me. The one remaining issue is that
svn and trac are out of sync, so that updates aren’t recording in trac, not visible in the Timeline and causing problems when Browsing Source. For the moment, I’m occassionally running “resync” with trac-admin. Any thoughts there?

One thought on “Trac on Dreamhost. A nightmare but maybe”

  1. Well I know MySQL support has been experimental for a while, and even though it’s in beta support now, all kinds of weird complexities can happen. I’m not sure why your Trac isn’t staying in sync, but I know you’ve spent way too much time trying to get this working. I can very much relate… heh… though you seem to be going through more trouble than usual.

    I would suggest a quick setup service like DevjaVu so you don’t have to worry about any of this nonsense ever again. 😉

Comments are closed.