Re: Fix for retry on serialization errors for ZPsycopgDA

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <1249827835.9296.27.camel@erin>
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.

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkp+2/sACgkQvcCgrgZGjeuFQACgx2+FQ306gteYfrW2bNnuzN5p
cqIAoKtISAlR0wtO5wbB1NaQRO3aWy9Z
=hcoC
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.