Modify

Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#5345 closed defect (fixed)

[Patch] TracError: The Trac Environment needs to be upgraded

Reported by: fruffell Owned by: Steffen Hoffmann
Priority: normal Component: TagsPlugin
Severity: normal Keywords: cursor upgrade error
Cc: lkraav Trac Release: 0.11

Description (last modified by Ryan J Ollos)

Setup:

Windows Server 2003
Apache 2.2
Python 2.5
Trac 0.11
TracTags 0.6

After installing and enabling TracTags in trac.ini, I get the following message:

TracError: The Trac Environment needs to be upgraded.

Run "trac-admin c:\projects\trac\unitronrdsoftwaregroupwiki upgrade"

Upgrade goes fine, restart Apache, same error.

Attachments (0)

Change History (24)

comment:1 Changed 15 years ago by ambling@…

same error for

  • Windows 2003 Server
  • Apache 2.0.63
  • Trac 0.11rc2
  • TagsPlugin 0.6

comment:2 Changed 15 years ago by Tobias

Same issue with:

Output of trac-admin <project> upgrade is:

Worklog needs an upgrade Upgrading Database Creating work_log table Updating work_log table (v2) Done upgrading Worklog Upgrade done.

The output of the second run of trac-admin <project> upgrade is the same.

comment:3 Changed 15 years ago by Tobias

I reckon that's the same as #3336.

comment:4 in reply to:  1 Changed 15 years ago by ambling@…

Replying to ambling@msn.com:

same error for

  • Windows 2003 Server
  • Apache 2.0.63
  • Trac 0.11rc2
  • TagsPlugin 0.6

after disable TagModelProvider, it works.

comment:5 Changed 15 years ago by christian.seiler@…

I ran into the same problem and tracked it down to a new version of pysqlite. The problem is that the cursor is created before calling self._need_migration in model.py and then that method creates another cursor itself. The old cursor is thus closed by pysqlite. When the migration-method returns no operation can be done on the old cursor anymore so an exception is thrown that the plugin interprets as that there is no table tags.

By the way, 0.4.1 is also affected (there it's api.py) which some people still use for Trac 0.10.

The following patch for 0.6 fixes it:

  • model.py

    old new  
    2020        self._upgrade_db(self.env.get_db_cnx())
    2121
    2222    def environment_needs_upgrade(self, db):
    23         cursor = db.cursor()
    2423        if self._need_migration(db):
    2524            return True
    2625        try:
     26            cursor = db.cursor()
    2727            cursor.execute("select count(*) from tags")
    2828            cursor.fetchone()
    2929            return False

comment:6 Changed 15 years ago by Alexandre Rocha

Yeah, the patch fixed it for me (winXP, Python 2.6, Trac 0.11)

comment:7 Changed 15 years ago by Ivan

same error after installing TagsPlugin and Environment upgrade:

  • Windows XP SP2
  • Apache 2.2.11
  • Trac 0.11.5
  • Python 2.6
  • pysqlite-2.5.5.win32-py2.6.exe
  • TagsPlugin 0.6
File "C:\Python26\lib\site-packages\trac\db\sqlite_backend.py", line 50, in _r
    return function(self, *args, **kwargs)
pysqlite2._sqlite.OperationalError: table tags already exists

The patch helped me too. Thanks!

comment:8 Changed 15 years ago by Daniel

I ran into the same problem as it seems, when upgrading from Ubuntu Jaunty to Karmic.

Traceback (most recent call last):
  File "/usr/local/bin/trac-admin", line 8, in <module>
    load_entry_point('Trac==0.11.5', 'console_scripts', 'trac-admin')()
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/admin/console.py", line 1314, in run
    return admin.onecmd(command)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/admin/console.py", line 133, in onecmd
    rv = cmd.Cmd.onecmd(self, line) or 0
  File "/usr/lib/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/admin/console.py", line 1154, in do_upgrade
    self.__env.upgrade(backup=do_backup)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/env.py", line 457, in upgrade
    participant.upgrade_environment(db)
  File "build/bdist.linux-i686/egg/tractags/model.py", line 35, in upgrade_environment
  File "build/bdist.linux-i686/egg/tractags/model.py", line 60, in _upgrade_db
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/db/util.py", line 60, in execute
    return self.cursor.execute(sql)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/db/sqlite_backend.py", line 58, in execute
    args or [])
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.5-py2.6.egg/trac/db/sqlite_backend.py", line 50, in _rollback_on_error
    return function(self, *args, **kwargs)
pysqlite2.dbapi2.OperationalError: table tags already exists

As there seems to be some solution for this problem mentioned above, could anyone point me to what I have to do now? Where do I find that file for applying the changes in this patch above (I don't see a patch-file)? What do I have to do next?

I really need my trac-environment up and running, so your help is really appreciated.

comment:9 Changed 15 years ago by Daniel

OK, replying myself. I figured it out and I now provide the solution for others having this problem:

Upgrading Ubuntu Jaunty to Karmic and fixing TracTags afterwards

  1. Deinstall and delete existing TracTags-plugin
    sudo easy_install -m TracTags
    sudo rm /usr/lib/python2.6/dist-packages/TracTags*
    
  1. Check out the source from trac-hacks and build an egg
    svn co http://trac-hacks.org/svn/tagsplugin/tags/0.6 TracTags
    cd TracTags
    python setup.py bdist_egg
    
  1. Install the egg
    cd dist
    sudo easy_install TracTags-0.6-py2.6.egg
    

Here you go, everything fine again.

comment:10 Changed 15 years ago by lkraav

Cc: lkraav added; anonymous removed

comment:11 Changed 15 years ago by Ryan J Ollos

Summary: TracError: The Trac Environment needs to be upgraded.[Patch] TracError: The Trac Environment needs to be upgraded

comment:12 Changed 15 years ago by p.labushev@…

Resolution: worksforme
Status: newclosed

Seems like for some of us it's a PYTHONPATH issue: trac-admin doesn't upgrade because it can't find the python modules of the participants who needs the upgrade. Just run trac-admin with the porper PYTHONPATH set. Worked for me.

comment:13 Changed 14 years ago by Vahid Pazirandeh

The patch listed in comment:5 worked for me. Thanks Christian.

I'm using Linux, Trac 0.11.5, Python 2.4, TracTags 0.6.

comment:14 Changed 14 years ago by anonymous

Another variant of this: my trac worked fine under tracd, but complained about needing an upgrade when run under mod_wsgi. Updating TagsPlugin to r7383 fixed it.

comment:15 Changed 14 years ago by Thomas Moschny

Similar problem here (Trac 0.11, TracTags 0.6) after upgrading the Linux distribution.

The patch from comment:5 helped.

comment:16 Changed 14 years ago by Ryan J Ollos

This is also discussed in #7504, so it seems the issue is not fixed, but at least there is still an open ticket for it.

comment:17 Changed 14 years ago by Ryan J Ollos

Description: modified (diff)

comment:18 Changed 13 years ago by gamesbook@…

Resolution: worksforme
Status: closedreopened

Problem still happening under Linux/Ubuntu 10.04, Trac 0.11.5, Python 2.6, TracTags 0.6.

comment:19 Changed 13 years ago by dnedelchev

We have the same problem @:

Linux/Ubuntu 11.04, Trac 0.12.3dev-r10716, Python 2.7.1+, TracTags just installed from latest source

comment:20 Changed 13 years ago by dnedelchev

sorry, the above message should be read "TracTags 0.6"

I've just installed the latest source from trunk and as I see the problem disappeared!

:)

comment:21 Changed 13 years ago by Steffen Hoffmann

Keywords: cursor error added
Owner: changed from Alec Thomas to Steffen Hoffmann
Status: reopenednew

#7504 has been closed as a duplicate, but contains a better, very valuable description compared to this one.

comment:22 Changed 13 years ago by Steffen Hoffmann

Resolution: fixed
Status: newclosed

(In [10382]) TagsPlugin: Obtain db cursor close to it's use, closed #5345.

This avoids issues of false positive checks here, but his is another issue. Just correct it now for both 0.6 and trunk.

comment:23 Changed 13 years ago by Steffen Hoffmann

(In [10384]) TagsPlugin: Don't catch all exceptions silently, refs #5345.

Errors from db operations throw not selectively catchable OperationalError, but don't swallow each and every exception without notice - at least log them.

comment:24 Changed 13 years ago by Ryan J Ollos

#8043 might be a duplicate. Requesting feedback in that ticket on possible resolution of issue with latest trunk.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.