psycopg2 vs psycopg1: the _v_database_connection problem in Zope 2
"Marco Bizzarri" <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi all. After hunting this problem a lot, in the end I was able to pin it. ZPsycopgDA for psycopg1, as many others database adapters in Zope, uses the _v_database_connection attribute to keep a connection per thread. The problem is that, under heavy load, the ZPsycopgDA object can be "ghostified", i.e. unloaded from the cache, and be recreated only later, when it is needed again. This, unfortunately, can happen within one transaction, thus potentially creating a situation where: a (Zope) transaction begins, a query to postgresql is issued, creating a new RDBMS transaction; an heavy load causes the ZPsycopgda to be ghostified; a new query causes the ZPsycopgDA to be loaded again, a new connection to the database is established; Of course, this can cause any sort of troubles to an application. Therefore, I'm asking if the psycopg2 adapter can suffer from the same problem; if it does not, it could be the "final" push for me to switch to psycopg2, after so many years of faithful psycopg1 use :-) Regards Marco -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/