Re: Psycopg 2.2.x issue with PgBouncer
Daniele Varrazzo <[email protected]> Thu, 5 Aug 2010 01:32:59 +0100
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Aug 2, 2010 at 8:21 AM, Marko Kreen <[email protected]> wrote: > On 8/2/10, Daniele Varrazzo <[email protected]> wrote: > You seem to forget that it can also call .commit(). =A0And in > autocommit mode the issue should not even arise, but I'm > not sure about current code... I've checked and the autocommit mode creates no problem to pgbouncer. If fog agrees to this change, I've prepared a patch (http://tinyurl.com/36qufm4) dropping the currently failing attempt to rollback and fixing the documentation for connection.close(), where I've added: Changed in version 2.2: previously an explicit ROLLBACK was issued by Psycopg on close(). The command could have been sent to the backend at an inappropriate time, so Psycopg currently relies on the backend to implicitly discard uncommitted changes. Some middleware are known to behave incorrectly though when the connection is closed during a transaction (when status is STATUS_IN_TRANSACTION), e.g. PgBouncer reports an unclean server and discards the connection. To avoid this problem you can ensure to terminate the transaction with a commit()/rollback() before closing. -- Daniele