Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9572 closed defect (fixed)

Attribute error reported

Reported by: tjb@… Owned by: Christian Boos
Priority: normal Milestone: 0.12.1
Component: database backend Version: 0.12-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I have just updated our trac to r10006 , sourced from the 0.12-stable branch, and found the following error.

Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/web/api.py", line 436, in send_error
    data, 'text/html')
  File "build/bdist.linux-i686/egg/trac/web/chrome.py", line 803, in render_template
    message = req.session.pop('chrome.%s.%d' % (type_, i))
  File "build/bdist.linux-i686/egg/trac/web/api.py", line 212, in __getattr__
    value = self.callbacks[name](self)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 298, in _get_session
    return Session(self.env, req)
  File "build/bdist.linux-i686/egg/trac/web/session.py", line 167, in __init__
    self.get_session(req.authname, authenticated=True)
  File "build/bdist.linux-i686/egg/trac/web/session.py", line 183, in get_session
    super(Session, self).get_session(sid, authenticated)
  File "build/bdist.linux-i686/egg/trac/web/session.py", line 57, in get_session
    cursor = db.cursor()
  File "build/bdist.linux-i686/egg/trac/db/util.py", line 102, in __getattr__
    return getattr(self.cnx, name)
AttributeError: 'tuple' object has no attribute 'cursor'

The same error had occurred at r10004, but not previously - I think the previous working version was r9999

I have also recently changed our trac runtime environment to use mod_wsgi instead of the prvious mod_python (apache 2.2). This setup was working prior to updating to trac0.12-stable r10004

Reverting to the prior working version fixes the problem

Our environment is:

  • Ubuntu 8.04LTS
  • Apache 2.2
  • python 2.5
  • subversion 1.6.11 (irrelevant I expect)
  • mod_wsgi 3.3

Attachments (0)

Change History (10)

comment:1 by tjb@…, 14 years ago

Correction, the prior working revision was r10001

comment:2 by Remy Blank, 14 years ago

Unfortunately, this is an error during the reporting of an error, so it's difficult to find the cause from this secondary traceback. Could you please look into your trac.log and see if you can find the primary traceback, that is, the traceback right before this one?

comment:3 by tjb@…, 14 years ago

Here is the contents of trac.log for the error - sorry for the delay.

2010-08-17 14:38:43,388 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 513, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 235, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/trac/wiki/web_ui.py", line 117, in process_request
    page = WikiPage(self.env, pagename)
  File "build/bdist.linux-i686/egg/trac/wiki/model.py", line 44, in __init__
    self._fetch(name, version, db)
  File "build/bdist.linux-i686/egg/trac/wiki/model.py", line 55, in _fetch
    db = self.env.get_db_cnx()
  File "build/bdist.linux-i686/egg/trac/env.py", line 326, in get_db_cnx
    return get_read_db(self)
  File "build/bdist.linux-i686/egg/trac/db/api.py", line 90, in get_read_db
    return _transaction_local.db or DatabaseManager(env).get_connection()
  File "build/bdist.linux-i686/egg/trac/db/api.py", line 152, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)
  File "build/bdist.linux-i686/egg/trac/db/pool.py", line 220, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "build/bdist.linux-i686/egg/trac/db/pool.py", line 114, in get_cnx
    cnx.close()
AttributeError: 'NoneType' object has no attribute 'close'

comment:4 by Remy Blank, 14 years ago

Component: generaldatabase backend
Milestone: 0.12.1

Thanks, that should help.

comment:5 by osimons, 14 years ago

I see this too on my development setup, and the error is reported consistently for certain requests. Exact same error(s). I just don't know why yet…

Christian, I'm on IRC as usual if you want to help me research this one… :-)

comment:6 by Christian Boos, 14 years ago

Well, the bug is clear now, but no idea why we didn't detect that mistake earlier when running the patch on t.e.o ;-)

  • trac/db/pool.py

    diff --git a/trac/db/pool.py b/trac/db/pool.py
    a b class ConnectionPoolBackend(object):  
    158158        # Forth best option: Replace a pooled connection with a new one
    159159        elif len(self._active) < self._maxsize:
    160160            # Remove the LRU connection in the pool
    161             self._pool.pop(0)
     161            cnx = self._pool.pop(0)
    162162            self._pool_key.pop(0)
    163163            self._pool_time.pop(0)
    164             return ('close', None)
     164            return ('close', cnx)
    165165
    166166    def _return_cnx(self, cnx, key, tid):
    167167        # Decrement active refcount, clear slot if 1

Could you please try the above fix?

in reply to:  6 comment:7 by Christian Boos, 14 years ago

Replying to cboos:

why we didn't detect that mistake earlier when running the patch on t.e.o …

… is because this code is only triggered when the same process serves different Trac environments (and different databases even, in case the environments correspond to different schemas), which is not the case on t.e.o which has dedicated processes for each environment.

comment:8 by osimons, 14 years ago

I see that the type of request that fails for me are the "forge"-type requests where same process:thread connects with more than one project and hence needs to open more more than a single connection (separate databases).

The patch fixes this. Goodie.

comment:9 by Christian Boos, 14 years ago

Resolution: fixed
Status: newclosed

Applied in r10039 for 0.12.1 and ported in trunk part of r10041.

comment:10 by Christian Boos, 14 years ago

Owner: set to Christian Boos

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.