Edgewall Software
Modify

Opened 9 years ago

Last modified 14 months ago

#12460 new defect

Environment.shutdown() drops all connections for both self and other environments in connection pool

Reported by: Jun Omae Owned by:
Priority: normal Milestone: next-stable-1.6.x
Component: database backend Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I think that result means Environment.shutdown() can wrongly close a database connection used for a other request on multi-threads in trac/web/main.py.

$ ~/venv/trac/1.0.10/bin/python
Python 2.5.6 (r256:88840, Oct 21 2014, 22:49:55)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import with_statement
>>> from trac.test import EnvironmentStub
>>> def fn():
...     env1 = EnvironmentStub()
...     env2 = EnvironmentStub()
...     with env1.db_query as db:
...         print(db('SELECT * FROM system'))
...         print(env2.db_query('SELECT * FROM system'))
...         env2.shutdown()
...         print(db('SELECT * FROM system'))
...
>>> fn()
[(u'database_version', u'29')]
[(u'database_version', u'29')]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 8, in fn
  File "/home/jun66j5/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/api.py", line 184, in __exit__
    self.db.close()
  File "/home/jun66j5/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/pool.py", line 51, in close
    self._pool._return_cnx(cnx, self._key, self._tid)
  File "/home/jun66j5/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/pool.py", line 166, in _return_cnx
    assert (tid, key) in self._active
AssertionError

Attachments (0)

Change History (4)

comment:1 by Ryan J Ollos, 9 years ago

Summary: Environment.shutdown() drops all connections for both self and other environements in connection poolEnvironment.shutdown() drops all connections for both self and other environments in connection pool

comment:2 by Ryan J Ollos, 8 years ago

Milestone: next-stable-1.0.xnext-stable-1.2.x

Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.

comment:3 by Ryan J Ollos, 5 years ago

Milestone: next-stable-1.2.xnext-stable-1.4.x

comment:4 by Ryan J Ollos, 14 months ago

Milestone: next-stable-1.4.xnext-stable-1.6.x

Milestone renamed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


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