Re: Fix for retry on serialization errors for ZPsycopgDA
Brian Sutherland <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
AARGH! Now that I actually am using the new version of psycopg2 I discover a brown-paper-bag bug in it. ZPsycopgDA/db.py needs an "import logging" at the top. Could you please add it or remove the calls to logging? 2009/8/9 Federico Di Gregorio <fog-NGVKUo/i/[email protected]>: > Il giorno gio, 25/06/2009 alle 13.56 +0200, Brian Sutherland ha scritto: >> >> I recently had the chance to look deeply into ZPsycopgDA's >> reconnect/retry behavior after upgrading psycopg2 to 2.0.7 (Debian Etch >> -> Lenny). We had random "InterfaceError: connection already closed" >> errors. >> >> It appeared that what happened was: >> >> * at some point serialization errors changed in psycopg2 from >> ProgrammingErrors to TransactionRollbackError (a sub-class >> of OperationalError) >> * This broke ZPsycopgDA's retry on serialization error, causing it >> think the connection had failed and disconnect >> * The disconnect was for all connections for all threads >> * Threads that had their connections closed mid-transaction raised >> InterfaceError >> >> Attached is a patch that fixes this and is tested with psycopg2 2.0.7, >> it does: >> >> * On a serialization error (TransactionRollbackError) raise >> ConflictError so the transaction can be re-tried >> * On any other OperationalError, dis-connect only the connection for >> the current thread and re-raise the error >> >> I think that that's more-or-less the correct behavior, but would be >> grateful to be proved wrong. > > It is a long time I don't use Zope but the patch seems fine to me so I > applied and will be in next release. > > federico > > -- > Federico Di Gregorio http://people.initd.org/fog > Debian GNU/Linux Developer [email protected] > INIT.D Developer fog-NGVKUo/i/[email protected] > I filosofi son come i sociologi: il mondo non lo capiscono. -- A.R.M. >