Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

Last modified 9 years ago

#9916 closed defect (duplicate)

TimeoutError: Unable to get database connection within 0 seconds.<trac.core.TracError instance at 0xa19044c>

Reported by: wang_yongjing@… Owned by: Christian Boos
Priority: high Milestone:
Component: database backend Version: 0.12.1
Severity: major Keywords: pool
Cc: Thijs Triemstra Branch:
Release Notes:
API Changes:
Internal Changes:

Description

How to Reproduce

While doing a GET operation on , Trac issued an internal error.

(please provide additional details here)

Request parameters:

{}

User agent: Mozilla/4#0 #compatible; MSIE 8#0; Windows NT 6#1; Trident/4#0; #R1 1#6#; SLCC2; #NET CLR 2#0#50727; #NET CLR 3#5#30729; #NET CLR 3#0#30729; Media Center PC 6#0#

System Information

System information not available

Enabled Plugins

Plugin information not available

Python Traceback

Traceback #most recent call last#:
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 511, in _dispatch_request
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 202, in dispatch
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 344, in _pre_process_request
  File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 330, in pre_process_request
  File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 503, in get_repository
  File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 571, in get_all_repositories
  File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 112, in get_repositories
  File "build/bdist.linux-i686/egg/trac/env.py", line 328, in get_db_cnx
  File "build/bdist.linux-i686/egg/trac/db/api.py", line 90, in get_read_db
  File "build/bdist.linux-i686/egg/trac/db/api.py", line 152, in get_connection
  File "build/bdist.linux-i686/egg/trac/db/pool.py", line 226, in get_cnx
  File "build/bdist.linux-i686/egg/trac/db/pool.py", line 146, in get_cnx
TimeoutError: Unable to get database connection within 0 seconds.
<trac.core.TracError instance at 0xa19044c>

Attachments (0)

Change History (19)

comment:1 by Christian Boos, 13 years ago

Milestone: 0.12.2
Priority: normalhigh
Severity: normalmajor

Weird, this was not supposed to be possible (see comment in tags/trac-0.12.1/trac/db/pool.py#L140).

Anything special in your setup? Tell us more about your database backend and server setup, as the relevant details have been stripped off your bug report.

comment:2 by Remy Blank, 13 years ago

OT: Where does this funny # escaping come from?

in reply to:  1 comment:3 by Christian Boos, 13 years ago

Keywords: needinfo added

… Tell us more about your database backend and server setup

Let me insist on this, as without additional hints, there's not much we can do.

comment:4 by bogdanovidiu.stanciu@…, 13 years ago

hi there!

it waqs not me, but i have the same issue.

here is my info:

System Information: Trac 0.12.1 Babel 0.9.4 Docutils 0.7 Genshi 0.6 mod_wsgi 3.2 (WSGIProcessGroup WSGIApplicationGroup ::1|/trac) Pygments 1.3.1 pysqlite 2.4.1 Python 2.6.6 (r266:84292, Sep 15 2010, 16:02:57) [GCC 4.4.5] pytz 2010b setuptools 0.6 SQLite 3.7.2 Subversion 1.6.12 (r955767)

running ubuntu 10.10.

comment:5 by bogdanovidiu.stanciu@…, 13 years ago

i set up a mysql db, with database = mysql://tracuser:xxxxxx@localhost/trac012 in trac.ini…

i can see only the sqlite refference….

comment:6 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added
Component: generaldatabase backend

comment:7 by anonymous, 13 years ago

i had the same error,

Its a shame but mysql server was not running.

comment:8 by Thijs Triemstra, 13 years ago

When running:

trac-admin ../test2/ version list

on 0.12-stable:

TimeoutError: Unable to get database connection within 0 seconds.
OperationalError(2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

comment:9 by Christian Boos, 13 years ago

Keywords: needinfo removed
Owner: set to Christian Boos

Good, that confirms what I suspected. We need to handle this situation explicitly.

comment:10 by Thijs Triemstra, 13 years ago

I guess connect_timeout could be set as well to prevent the 0 seconds thing.

comment:11 by Christian Boos, 13 years ago

Priority: highlow

Actually the only thing I don't get here is how the reporter could have received:

TimeoutError: Unable to get database connection within 0 seconds.
<trac.core.TracError instance at 0xa19044c>

i.e. the instance instead of the proper TracError(...) output.

We do a '%r' formatting on the exception, and most of the time this yields informative output like shown in comment:8. Same should happen for a TracError:

>>> from trac.core import TracError
>>> '\n%r' % TracError("bzt")
"\nTracError('bzt',)"

and that's indeed what Trac reports when I explicitly raise a TracError from the pool code.

So for now I don't see what to change here:

  • lacking a database connection is a fatal error and deserves an internal error
  • the internal error is normally informative enough to determine the reason for the failure
  • I have no idea how to trigger the display of <trac.core.TracError instance at ...> as originally reported…

comment:12 by anonymous, 13 years ago

We had the same error, here the log, hope helpful.

2011-01-18 09:34:34,084 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "D:\Python25\Lib\site-packages\trac\web\main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "D:\Python25\Lib\site-packages\trac\web\main.py", line 202, in dispatch
    chosen_handler)
  File "D:\Python25\Lib\site-packages\trac\web\main.py", line 344, in _pre_process_request
    chosen_handler = filter_.pre_process_request(req, chosen_handler)
  File "D:\Python25\lib\site-packages\trac\versioncontrol\api.py", line 327, in pre_process_request
    if is_default(reponame):
  File "D:\Python25\lib\site-packages\trac\versioncontrol\api.py", line 32, in is_default
    return not reponame or reponame in ('(default)', _('(default)'))
  File "D:\Python25\Lib\site-packages\trac\util\translation.py", line 188, in gettext
    if not self.isactive:
  File "D:\Python25\Lib\site-packages\trac\util\translation.py", line 177, in isactive
    self.activate(get_locale(), env_path)
  File "D:\Python25\Lib\site-packages\trac\web\main.py", line 477, in <lambda>
    translation.make_activable(lambda: req.locale, env and env.path or None)
  File "D:\Python25\Lib\site-packages\trac\web\api.py", line 212, in __getattr__
    value = self.callbacks[name](self)
  File "D:\Python25\Lib\site-packages\trac\web\main.py", line 308, in _get_locale
    preferred = req.session.get('language')
  File "D:\Python25\Lib\site-packages\trac\web\api.py", line 212, in __getattr__
    value = self.callbacks[name](self)
  File "D:\Python25\Lib\site-packages\trac\web\main.py", line 300, in _get_session
    return Session(self.env, req)
  File "D:\Python25\Lib\site-packages\trac\web\session.py", line 167, in __init__
    self.get_session(req.authname, authenticated=True)
  File "D:\Python25\Lib\site-packages\trac\web\session.py", line 183, in get_session
    super(Session, self).get_session(sid, authenticated)
  File "D:\Python25\Lib\site-packages\trac\web\session.py", line 56, in get_session
    db = self.env.get_db_cnx()
  File "D:\Python25\Lib\site-packages\trac\env.py", line 328, in get_db_cnx
    return get_read_db(self)
  File "D:\Python25\Lib\site-packages\trac\db\api.py", line 90, in get_read_db
    return _transaction_local.db or DatabaseManager(env).get_connection()
  File "D:\Python25\Lib\site-packages\trac\db\api.py", line 152, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)
  File "D:\Python25\Lib\site-packages\trac\db\pool.py", line 226, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "D:\Python25\Lib\site-packages\trac\db\pool.py", line 146, in get_cnx
    raise TimeoutError(errmsg)
TimeoutError: Unable to get database connection within 0 seconds.

in reply to:  12 ; comment:13 by Christian Boos, 13 years ago

Replying to anonymous:

We had the same error, here the log, hope helpful.

2011-01-18 09:34:34,084 Trac[main] ERROR: Internal Server Error: 
...
TimeoutError: Unable to get database connection within 0 seconds.

Are you sure the backtrace ends like that? The line immediately following the TimeoutError one should normally contain the original error. I'll change the error message to be all in one line for the next version.

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

Keywords: pool added
Milestone: 0.12.2next-minor-0.12.x
Priority: lowhigh

the error message (is now) on a single line for the next version.

While problems like comment:8 are clear and self describing, we need more information about what happened exactly for the original reporter (the <trac.core.TracError instance at 0xa19044c>) and for comment:12 (r10461 should help here), so I'm postponing this ticket.

comment:15 by Christian Boos, 13 years ago

Milestone: next-minor-0.12.x
Resolution: duplicate
Status: newclosed

As we didn't get feedback form the original reporter, let's try to continue debugging this with someone else, on #10024.

Last edited 13 years ago by Christian Boos (previous) (diff)

in reply to:  11 comment:16 by Christian Boos, 13 years ago

Replying to cboos:

We do a '%r' formatting on the exception, and most of the time this yields informative output like shown in comment:8. Same should happen for a TracError:

>>> from trac.core import TracError
>>> '\n%r' % TracError("bzt")
"\nTracError('bzt',)"

Except for Python 2.4:

>>> from trac.core import TracError
>>> '\n%r' % TracError("bzt")
'\n<trac.core.TracError instance at 0x01EC1210>'

comment:17 by chrisweed@…, 12 years ago

FYI, I was getting this same error, and I was able to fix it by changing the ownership of the files in my project env directory from root to www-data.

in reply to:  17 comment:18 by anonymous, 12 years ago

Replying to chrisweed@…:

FYI, I was getting this same error, and I was able to fix it by changing the ownership of the files in my project env directory from root to www-data.

i'll second that. the fix worked for me, too:

# chown www-data.www-data /path/to/repos -R

cheers, -e

comment:19 by anonymous, 9 years ago

Ahh, permissions problems….

chown www-data:www-data /path/to/tracenv -R

Solved my database timeout issue.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

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.