Opened 6 years ago
Installation fails with PostgreSQL database backend
|Reported by:||anonymous||Owned by:||coling|
I installed WorkLogPlugin using easy_install, edited my trac.ini to include:
worklog.* = enabled [worklog] timingandestimation = true
I then ran:
trac-admin /var/trac upgrade
And it failed with:
Worklog needs an upgrade * Upgrading Database Creating work_log table InternalError: current transaction is aborted, commands ignored until end of transaction block
I examined the code in api.py and traced the problem to the following section:
def do_db_upgrade(self, db): # Legacy support hack (supports upgrades from revisions r2495 or before) if self.db_installed_version == 0: try: cursor = self.env.get_read_db().cursor() cursor.execute('SELECT * FROM work_log LIMIT 1') # We've succeeded so we actually have version 1 self.db_installed_version = 1 except: self.db_installed_version = 0
What I believe is happening is the SELECT command fails with an error. In PostgreSQL, this invalidates the transaction until a rollback is performed. There is no rollback in the code, so when the function later tries to create a table, the InternalError is generated.
I was able to work around the problem by commenting out the SELECT test and simply setting db_installed_version to zero (which works because this is a fresh install), but I don't know the whole installation workflow well enough to suggest a permanent fix. My guess is that rolling back the transaction is bad because it might undo changes done by other plugins installed at the same time. I think that you probably need to use an alternate method of determining if the table exists or not.