[Zope] Problem with Z Psycopg
Barry Pederson
bp at barryp.org
Tue Apr 5 14:12:28 EDT 2005
Jason Leach wrote:
> I'm having a problem with Z Psycopg. From time to time (quite often)
> it looses the connection with the database and I get:
> Site Error
> An error was encountered while publishing this resource.
> Error Type: OperationalError
> Error Value: no connection to the server
Garth B. wrote:
> I have the same problem, but I eventually "corrected" it, by forcibly
> closing the connection each time prior to running the queries.
> Fortunately, my scenario uses page caching to reduce the number of hits
> to the db so the additional effort of reopening the connection is neglible.
>
> I'd sure like to know what the problem is, though...
I've been looking at the differences between ZPsycopg that comes with 1.0.x and
1.1.x, and it looks like the older ZPsycopg had code to automatically reconnect
on an OperationalError (in db.py, the DB.query() method), but the corresponding
method in the newer ZPsycopg doesn't have that. Looks like it was removed in
1.1.11 or 1.1.12
I'm trying this patch to see if it gets back the reliability my old setup had -
although I'm not sure what other bad stuff this could cause
--------------------------
--- db.py.original Fri Oct 29 19:19:27 2004
+++ db.py Tue Apr 5 12:56:46 2005
@@ -222,7 +222,12 @@
result = c.fetchall()
desc = c.description
self.failures = 0
-
+
+ except psycopg.OperationalError, err:
+ if hasattr(self, 'db'):
+ del c; del self.db
+ return self.query(query_string, max_rows, query_data)
+
except StandardError, err:
self._abort()
raise err
--------------------------
Barry
More information about the Zope
mailing list