#3394: trac fails to use cached postgresql connection
-------------------------------------------+--------------------------------
Reporter: [EMAIL PROTECTED] | Owner: cmlenz
Type: defect | Status: assigned
Priority: normal | Milestone: 0.10
Component: mod_python frontend | Version: 0.9.6
Severity: major | Resolution:
Keywords: postgresql connection timeout |
-------------------------------------------+--------------------------------
Changes (by cmlenz):
* milestone: => 0.10
* status: new => assigned
Old description:
> One morning I came into work to find trac making these noises in stead of
> working, we're using Trac 0.9.6 on top of postgresql, after restarting
> apache, trac returned to its normal self.
>
> I've checked with the postgresql docs and pg doesn't have connection
> timeouts.
>
> The problem is reproducible by:
> * Starting apache and requesting a couple of trac pages.
> * Restarting pg
> * Requesting another trac page.
>
> The problem seems to be slightly related to #2437.
>
> I have not looked at the code yet, but all other connection pooling
> systems I've seen start by testing the connection if it was pulled from
> the cache, this test is obviously missing or broken in trac.
>
> ------------------
>
> Oops...
>
> Trac detected an internal error:
>
> FATAL: terminating connection due to administrator command
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
>
> Traceback (most recent call last):
> File "/usr/local/lib/python2.4/site-
> packages/trac/web/modpython_frontend.py", line 206, in handler
> dispatch_request(mpr.path_info, mpr, env)
> File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line
> 139, in dispatch_request
> dispatcher.dispatch(req)
> File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line
> 80, in dispatch
> req.perm = PermissionCache(self.env, req.authname)
> File "/usr/local/lib/python2.4/site-packages/trac/perm.py", line 276,
> in __init__
> self.perms = PermissionSystem(env).get_user_permissions(username)
> File "/usr/local/lib/python2.4/site-packages/trac/perm.py", line 132,
> in get_user_permissions
> for perm in self.store.get_user_permissions(username):
> File "/usr/local/lib/python2.4/site-packages/trac/perm.py", line 212,
> in get_user_permissions
> cursor = db.cursor()
> File "/usr/local/lib/python2.4/site-packages/trac/db.py", line 106, in
> cursor
> return IterableCursor(self.cnx.cursor())
> File "/usr/local/lib/python2.4/site-packages/trac/db.py", line 106, in
> cursor
> return IterableCursor(self.cnx.cursor())
> File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line
> 2599, in cursor
> return Cursor(self, name, isRefCursor)
> File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line
> 2718, in __init__
> self.conn._Connection__setupTransaction()
> File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line
> 2510, in __setupTransaction
> self.conn.query("BEGIN WORK")
> OperationalError: FATAL: terminating connection due to administrator
> command
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
New description:
One morning I came into work to find trac making these noises in stead of
working, we're using Trac 0.9.6 on top of postgresql, after restarting
apache, trac returned to its normal self.
I've checked with the postgresql docs and pg doesn't have connection
timeouts.
The problem is reproducible by:
* Starting apache and requesting a couple of trac pages.
* Restarting pg
* Requesting another trac page.
The problem seems to be slightly related to #2437.
I have not looked at the code yet, but all other connection pooling
systems I've seen start by testing the connection if it was pulled from
the cache, this test is obviously missing or broken in trac.
{{{
Oops...
Trac detected an internal error:
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-
packages/trac/web/modpython_frontend.py", line 206, in handler
dispatch_request(mpr.path_info, mpr, env)
File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line
139, in dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 80,
in dispatch
req.perm = PermissionCache(self.env, req.authname)
File "/usr/local/lib/python2.4/site-packages/trac/perm.py", line 276, in
__init__
self.perms = PermissionSystem(env).get_user_permissions(username)
File "/usr/local/lib/python2.4/site-packages/trac/perm.py", line 132, in
get_user_permissions
for perm in self.store.get_user_permissions(username):
File "/usr/local/lib/python2.4/site-packages/trac/perm.py", line 212, in
get_user_permissions
cursor = db.cursor()
File "/usr/local/lib/python2.4/site-packages/trac/db.py", line 106, in
cursor
return IterableCursor(self.cnx.cursor())
File "/usr/local/lib/python2.4/site-packages/trac/db.py", line 106, in
cursor
return IterableCursor(self.cnx.cursor())
File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line
2599, in cursor
return Cursor(self, name, isRefCursor)
File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line
2718, in __init__
self.conn._Connection__setupTransaction()
File "/usr/local/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line
2510, in __setupTransaction
self.conn.query("BEGIN WORK")
OperationalError: FATAL: terminating connection due to administrator
command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
}}}
Comment:
Thanks for the patch!
--
Ticket URL: <http://trac.edgewall.org/ticket/3394>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets