Psycopg 2.2.x issue with PgBouncer

Jason Yan <[email protected]> Fri, 23 Jul 2010 16:45:21 -0700
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
I'm seeing an issue with how Psycopg 2.2.x handles connections with
PgBouncer. =A0After a connection is closed, PgBouncer spits out the
following:
=A0=A02010-07-23 16:33:46.407 5282 LOG C-0x1e9ad80:
test/[email protected]:33306 login successful: db=3Dtest user=3Dpostgres
=A0=A02010-07-23 16:33:46.407 5282 LOG S-0x1eb8280:
test/[email protected]:5432 new connection to server
=A0=A02010-07-23 16:33:46.411 5282 LOG C-0x1e9ad80:
test/[email protected]:33306 closing because: client close request
(age=3D0)
=A0=A02010-07-23 16:33:46.411 5282 LOG S-0x1eb8280:
test/[email protected]:5432 closing because: unclean server (age=3D0)

This kills PgBouncer's server backend which effectively kills
connection pooling. =A0I've reproduced this behavior with both 2.2.1 and
2.2.2, but I've verified that 2.0.14 does not have this issue. =A0I'm
running a clean build of PgBouncer 1.3.3 with the default
configuration on Ubuntu 9.04 64-bit with the following PostgreSQL
packages:
=A0=A0ii =A0postgresql =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 8.3.11-0ubuntu9.04
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 object-relatio=
nal SQL database
(supported ve
=A0=A0ii =A0postgresql-8.3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 8.3.11-0ubuntu9.04
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 object-relatio=
nal SQL database, version
8.3
=A0=A0ii =A0postgresql-client-8.3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A08.3.11-0ubuntu9.04
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 front-end prog=
rams for PostgreSQL 8.3
=A0=A0ii =A0postgresql-client-common =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 97
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 manager for mu=
ltiple PostgreSQL client
versi
=A0=A0ii =A0postgresql-common =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A097
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PostgreSQL dat=
abase-cluster manager
=A0=A0ii =A0postgresql-contrib-8.3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
8.3.11-0ubuntu9.04
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 additional fac=
ilities for PostgreSQL

And the small test script that I'm reproducing the issue with:
=A0=A0import psycopg2
=A0=A0connection =3D psycopg2.connect("dbname=3Dtest user=3Dpostgres
host=3Dlocalhost port=3D6432")
=A0=A0cursor =3D connection.cursor()
=A0=A0cursor.execute("SELECT 1")
=A0=A0connection.close()

Thanks,
Jason