Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#2016 closed defect (fixed)

hotcopy depends on PySQLite 1.x

Reported by: pellatt@… Owned by: Christopher Lenz
Priority: high Milestone: 0.9
Component: admin/console Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description

I'm on the latest trunk, running on Windows 2003 Server, and get this stack trace:

Trac [<repopath>]> hotcopy \tr
Traceback (most recent call last):
  File "trac-admin", line 26, in ?
    run(*sys.argv[1:])
  File "C:\Program Files\Python23\Lib\site-packages\trac\scripts \admin.py",
 1085, in run
    tracadm.run()
  File "C:\Program Files\Python23\Lib\site-packages\trac\scripts \admin.py",
 82, in run
    self.cmdloop()
  File "C:\Program Files\Python23\lib\cmd.py", line 133, in cmdloop
    stop = self.onecmd(line)
  File "C:\Program Files\Python23\lib\cmd.py", line 210, in onecmd
    return func(arg)
  File "C:\Program Files\Python23\Lib\site-packages\trac\scripts \admin.py",
 1053, in do_hotcopy
    cnx.db.execute("BEGIN")
  File "C:\Program Files\Python23\Lib\site-packages\trac\db.py",  line 101,
getattr__
    return getattr(self.cnx, name)
  File "C:\Program Files\Python23\Lib\site-packages\trac\db.py",  line 101,
getattr__
    return getattr(self.cnx, name)
AttributeError: 'pysqlite2.dbapi2.Connection' object has no  attribute 'db'

Other trac admin commands seem to work fine, as does normal use of the wiki etc.

FYI - the other versions I have are clearilver 0.9.14, docutils 0.3.9, pysqlite 2.0.3, sqlite 3.2.5, svn 1.2.3.

Response from the mailing list was "This is a leftover from when we only supported SQLite, and only PySQLite 1.x. ".

Attachments (0)

Change History (6)

comment:1 by Christopher Lenz, 14 years ago

Milestone: 0.9
Priority: normalhigh

comment:2 by Christopher Lenz, 14 years ago

Summary: hotcopy crasheshotcopy depends on PySQLite 1.x

Better summary

comment:3 by Christopher Lenz, 14 years ago

The following patch resolves this problem:

  • trac/scripts/admin.py

     
    10501050            return
    10511051        cnx = self.db_open()
    10521052        # Lock the database while copying files
    1053         cnx.db.execute("BEGIN")
    1054         print 'Hotcopying %s to %s ...' % (self.__env.path, dest),
     1053        cursor = cnx.cursor()
     1054        print 'Hotcopying %s to %s ...' % (self.__env.path, dest)
    10551055        try:
    10561056            shutil.copytree(self.__env.path, dest, symlinks=1)
    10571057            print 'OK'
    10581058        except Exception, err:
    10591059            print err
    10601060        # Unlock database
    1061         cnx.db.execute("ROLLBACK")
     1061        cnx.rollback()
    10621062
    10631063## ---------------------------------------------------------------------------
    10641064

However, I'm not sure whether this actually locks the database during hotcopy.

comment:4 by Matthew Good, 14 years ago

Simply opening a cursor to the database doesn't lock it. Executing BEGIN in a pysqlite2 cursor doesn't seem to actually lock the database (though it confuses pysqlite2 since it tries to start transactions itself when you run a query that may update the database.

As far as I can tell the only way to lock the database with pysqlite2 is to execute an INSERT/UPDATE/DELETE statement. I suppose that one option would be to simply run an innocuous statement that wouldn't change anything, but would force it to lock the database:

update system set name = null where name is null

comment:5 by Christopher Lenz, 14 years ago

Owner: changed from daniel to Christopher Lenz
Status: newassigned

Yeah, that's probably the best we can do here. I'll make that change.

comment:6 by Christopher Lenz, 14 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [2263].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.