Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#11246 closed defect (fixed)

Fatal error on database migration with Trac v1.0.1

Reported by: ryank-inovonics Owned by: jun66j5
Priority: highest Component: TracMigratePlugin
Severity: blocker Keywords: feedback
Cc: Trac Release: 1.0


When attempting to migrate a Trac v1.0.1 site from SQLite to PostgreSQL, got this error:

Copying tables:
ProgrammingError: Cannot operate on a closed database.
Exception AssertionError: AssertionError() in <bound method PooledConnection.__del__ of <trac.db.pool.PooledConnection object at 0x95ef324>> ignored
    attachment table...

After poking around in found that creating the new environment closes any existing database connections, namely the one for the old environment's SQLite database. Swapped the new environment creation section with old environment's database open and query. With this change the migration completed successfully. See attached diff for the changes made to

Maybe a change in behavior of environment creation in Trac 1.0.x?

Attachments (1)

admin.diff (885 bytes) - added by ryank-inovonics 21 months ago.

Download all attachments as: .zip

Change History (6)

Changed 21 months ago by ryank-inovonics

comment:1 Changed 21 months ago by jun66j5

Thanks for the patch. Looks harmless. But I cannot reproduce it with Python 2.5/2.6/2.7 while migrating SQLite to PostgreSQL. Could you please provide the details of your environment?

comment:2 Changed 21 months ago by jun66j5

  • Keywords feedback added

comment:3 Changed 21 months ago by ryank-inovonics

Environment details:

  • Ubuntu 12.04
  • Python 2.7.3
  • Trac 1.0.1
  • PostgreSQL 9.1.9
  • SQLite 3.7.9 & SQLite 2.8.17

Using a Python virtualenv with these packages installed (pip list):

AdvancedTicketWorkflowPlugin (0.11dev-r9962)
argparse (1.2.1)
BlackMagicTicketTweaks (0.11r1)
distribute (0.6.38)
docutils (0.10)
flup (
Genshi (0.7)
NavAdd (0.1.1)
PlantUML (2.0dev-r12389)
psycopg2 (2.5)
Pygments (1.6)
pytz (2013b)
Trac (1.0.1)
TracAccountManager (0.4.3)
TracCustomFieldAdmin (0.2.8-r12166)
TracIniAdminPanel (1.0.1-r13010)
TracMasterTickets (3.0.5dev-r12950)
TracMigratePlugin (
TracPermRedirect (3.0)
TracWysiwyg (
wsgiref (0.1.2)

Maybe one of the Trac plugins I have installed has a side-effect of closing the open database connections on environment create?

comment:4 Changed 21 months ago by jun66j5

  • Resolution set to fixed
  • Status changed from new to closed

In 13348:

tracmigrate: makes migration more robust by retrieving connection after upgrade of new environment (closes #11246)

Patch by ryank-inovonics.

comment:5 Changed 21 months ago by jun66j5

Thanks for your providing the details. Reproduced with only Trac 1.0.1, MasterTicketsPlugin and TracMigratePlugin

Great Catching! Many thanks!

Add Comment

Modify Ticket

as closed The owner will remain jun66j5.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.