Modify

Opened 13 years ago

Closed 13 years ago

#8854 closed defect (fixed)

'Environment' object has no attribute 'get_read_db'

Reported by: anonymous Owned by: Russ Tyndall
Priority: highest Component: TimingAndEstimationPlugin
Severity: blocker Keywords:
Cc: Russ Tyndall Trac Release: 0.12

Description (last modified by Ryan J Ollos)

hi,

after installing 0.12 version in Ubuntu Linux 10.04.1 and enabling it in the admin section, I ran the trac-admin command:

trac-admin /var/local/lib/trac/git-Development upgrade

and I got this reply:

----

Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/trac/web/api.py", line 376, in send_error
    'text/html')
  File "/usr/lib/python2.6/dist-packages/trac/web/chrome.py", line 745, in render_template
    stream |= self._filter_stream(req, method, filename, stream, data)
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 128, in __or__
    return Stream(_ensure(function(self)), serializer=self.serializer)
  File "/usr/lib/python2.6/dist-packages/trac/web/chrome.py", line 848, in inner
    data)
  File "/usr/local/lib/python2.6/dist-packages/timingandestimationplugin-1.1.4-py2.6.egg/timingandestimationplugin/tande_filters.py", line 115, in filter_stream
    ).apply(FilterTransformation(RowFilter(self)))
  File "/usr/local/lib/python2.6/dist-packages/timingandestimationplugin-1.1.4-py2.6.egg/timingandestimationplugin/tande_filters.py", line 39, in __init__
    rows = dbhelper.get_all(comp.env, "SELECT id FROM custom_report")[1]
  File "/usr/local/lib/python2.6/dist-packages/timingandestimationplugin-1.1.4-py2.6.egg/timingandestimationplugin/dbhelper.py", line 4, in get_all
    db = env.get_read_db()
AttributeError: 'Environment' object has no attribute 'get_read_db'
 ----

Now I can't access TRAC at all, it seems broken

what the ?

Attachments (0)

Change History (10)

comment:1 Changed 13 years ago by anonymous

I've even removed it from the ini file, and this message still persists

comment:2 Changed 13 years ago by Ryan J Ollos

Description: modified (diff)

Note that the errors are coming from the TimingAndEstimationPlugin.

comment:3 Changed 13 years ago by Ryan J Ollos

Cc: Russ Tyndall added; anonymous removed

comment:4 Changed 13 years ago by Chris Nelson

Component: TracJsGanttPluginTimingAndEstimationPlugin
Owner: changed from Chris Nelson to Russ Tyndall

comment:5 Changed 13 years ago by Russ Tyndall

Status: newassigned

The timingandestimationplugin is fairly well tested on trac 12, so it is interesting you are getting this error. Also, the environment really should have a get_read_db function on it. This implies to me that some part of your upgrade did not go quite according to plan. It almost seems like it is trying to load an earlier version of trac.

If you su to the user running the webserver (www-data), can you connect to the database in python

import trac
trac.__version__   # verify that this returns a trac 12 version
>> '0.12.3dev-r10639'

# verify you can connect to the database from python
import trac.env
e = trac.env.Environment('/var/trac/test') # enter your trac instance directory
db = e.get_read_db()
cur = db.cursor()
cur.execute("SELECT 1")
data = cur.fetchone()

Please let me know if this helps resolve your issues, if not we can dig further.

Cheers, Russ

comment:6 in reply to:  5 ; Changed 13 years ago by scarabx@…

I have a similar issue as the OP. I tried the steps you outlined and it failed at the db = e.get_read_db(). Output is below:

>>> import trac
>>> trac.__version__
'0.12.2'
>>> import trac.env
>>> e = trac.env.Environment('/trac/myproject')
>>> db = e.get_read_db()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/trac/env.py", line 340, in get_read_db
    return get_read_db(self)
  File "/usr/lib/python2.7/site-packages/trac/db/api.py", line 90, in get_read_db
    return _transaction_local.db or DatabaseManager(env).get_connection()
  File "/usr/lib/python2.7/site-packages/trac/db/api.py", line 152, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)
  File "/usr/lib/python2.7/site-packages/trac/db/pool.py", line 226, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "/usr/lib/python2.7/site-packages/trac/db/pool.py", line 146, in get_cnx
    raise TimeoutError(errmsg)
trac.db.pool.TimeoutError: Unable to get database connection within 0 seconds. (TracError(<babel.support.LazyProxy object at 0x19f8280>,))

I'm using a MySQL database as the data storage for the trac instance and the site itself is live with some other plugins working.

Replying to bobbysmith007:

The timingandestimationplugin is fairly well tested on trac 12, so it is interesting you are getting this error. Also, the environment really should have a get_read_db function on it. This implies to me that some part of your upgrade did not go quite according to plan. It almost seems like it is trying to load an earlier version of trac.

If you su to the user running the webserver (www-data), can you connect to the database in python

import trac
trac.__version__   # verify that this returns a trac 12 version
>> '0.12.3dev-r10639'

# verify you can connect to the database from python
import trac.env
e = trac.env.Environment('/var/trac/test') # enter your trac instance directory
db = e.get_read_db()
cur = db.cursor()
cur.execute("SELECT 1")
data = cur.fetchone()

Please let me know if this helps resolve your issues, if not we can dig further.

Cheers, Russ

comment:7 in reply to:  6 Changed 13 years ago by Russ Tyndall

Replying to scarabx@gmail.com:

I have a similar issue as the OP. I tried the steps you outlined and it failed at the db = e.get_read_db(). Output is below: trac.db.pool.TimeoutError: Unable to get database connection within 0 seconds. (TracError(<babel.support.LazyProxy object at 0x19f8280>,))

I'm using a MySQL database as the data storage for the trac instance and the site itself is live with some other plugins working.

This is actually a different error, caused by being unable to connect to the database. It sounds like you might have something wrong in configuration (eg, permissions on trac.ini are wrong and it cannot read your database user and password, or something similar). If you cannot get_read_db, I dont think it is related to this plugin, other than that this plugin calls get_read_db. Does disabling the plugin fix the problem? It is possible that TimingAndEstimationPlugin somehow exacerbates an existing problem in some setups I suppose, though it does seem to work fine for many people.

I also see many related trac errors, t:#9111 ,t:#9916, t:#10024.

Please let me know if you are still experiencing the problem, after checking for answers there.


Also I will need the pertinent version numbers from the trac about page and your database backend versions to even begin to debug these issues.

  • Please verify that your webserver user can read your trac.ini - this leads to many spurious errors in trac12

comment:8 Changed 13 years ago by anonymous

Ok, so I restarted the MySQL server and tried the diagnostic code and it worked. After that, I enabled the TimingAndEstimationPlugin (all features), tried a "trac-admin <proj> upgrade", and got the following:

Timing and Estimation needs an upgrade
Upgrading Database
Creating bill_date table
Upgrading reports
/usr/lib/python2.7/site-packages/trac/db/util.py:66: Warning: Some non-transactional changed tables couldn't be rolled back
  return self.cursor.execute(sql)
Upgrading fields
Upgrading usermanual
Done Upgrading
Upgrade done.

You may want to upgrade the Trac documentation now by running:

  trac-admin <myproj> wiki upgrade

After getting this, I refreshed the trac site in the browser and got the connection timeout error again (see below):

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/web/api.py", line 440, in send_error
    data, 'text/html')
  File "/usr/lib/python2.7/site-packages/trac/web/chrome.py", line 827, in render_template
    message = req.session.pop('chrome.%s.%d' % (type_, i))
  File "/usr/lib/python2.7/site-packages/trac/web/api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 300, in _get_session
    return Session(self.env, req)
  File "/usr/lib/python2.7/site-packages/trac/web/session.py", line 192, in __init__
    if req.authname == 'anonymous':
  File "/usr/lib/python2.7/site-packages/trac/web/api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 159, in authenticate
    authname = authenticator.authenticate(req)
  File "/usr/lib/python2.7/site-packages/trac/web/auth.py", line 83, in authenticate
    authname = self._get_name_for_cookie(req, req.incookie['trac_auth'])
  File "/usr/lib/python2.7/site-packages/trac/web/auth.py", line 212, in _get_name_for_cookie
    db = self.env.get_db_cnx()
  File "/usr/lib/python2.7/site-packages/trac/env.py", line 328, in get_db_cnx
    return get_read_db(self)
  File "/usr/lib/python2.7/site-packages/trac/db/api.py", line 90, in get_read_db
    return _transaction_local.db or DatabaseManager(env).get_connection()
  File "/usr/lib/python2.7/site-packages/trac/db/api.py", line 152, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)
  File "/usr/lib/python2.7/site-packages/trac/db/pool.py", line 226, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "/usr/lib/python2.7/site-packages/trac/db/pool.py", line 146, in get_cnx
    raise TimeoutError(errmsg)
TimeoutError: Unable to get database connection within 0 seconds. (TracError(<babel.support.LazyProxy object at 0x7fe1d6e089b0>,))

It looks like there is definitely something going on with the connection pools. I restarted both Apache and MySQL after this error, refreshed the trac project and same error as above which leaves the project in an unusable state.

System Info:

System Information

Trac	        0.12.2
Babel	        0.9.5
Docutils	0.7
Genshi	        0.6
GIT	        1.7.3.4
mod_wsgi	3.3 (WSGIProcessGroup WSGIApplicationGroup %{GLOBAL})
MySQL	server: "5.1.53", client: "5.1.53", thread-safe: 1
MySQLdb	        1.2.3
Pygments	1.3.1
Python	        2.7 (r27:82500, Aug 07 2010, 16:54:59) [GCC]
pytz	        2010h
setuptools	0.6c12
Subversion	1.6.17 (r1128011)
jQuery:	        1.4.2

Installed Plugins

IniAdmin      	                0.2
NavAdd   	                0.1
timingandestimationplugin	1.1.6b
TracAccess	                0.1	
TracAccountManager	        0.3dev-r10380	
TracGit	                        0.12.0.2dev-r7757	
TracIniAdminPanel	        0.81beta	
TracNewsFlash	                1.0.1	
TracProtected	                2.1.1	
TracTocMacro	                11.0.0.3	
worklog	                        0.1	

comment:9 in reply to:  8 ; Changed 13 years ago by scarabx@…

Alrite, problem solved. Hit me with the dumb stick!

Problem was that the trac.ini file was not readable by the user the server is running as. Somewhere along the way I must have changed the perms.

Thanks for all the help!

comment:10 in reply to:  9 Changed 13 years ago by Russ Tyndall

Resolution: fixed
Status: assignedclosed

Replying to scarabx@gmail.com:

Problem was that the trac.ini file was not readable by the user the server is running as. Somewhere along the way I must have changed the perms.

This has far and away been the most reported bug since the release of trac 12. I think they have already fixed the error message in trac 13. (At least there are patch suggestions to do so).

Glad we got it fixed, If anonymous reporter comes back and has more questions feel free to reopen.

Russ

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Russ Tyndall.
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.