News for hackers. Stuff that matters.
Re:Fixing Database Connections in Django by rosser on Friday March 08, 2013 @04:31PM (#5345863)
If you're using a connection pooler with Django — or really, anything SQL database related in Python — please be mindful that the Python DB API is implicitly transactional. That is, if you say:

  SELECT COUNT(*) FROM users;
DBAPI says:

  BEGIN;
  SELECT COUNT(*) FROM users;
...and leaves the COMMIT or ROLLBACK of that transaction up to you.

Aside from the severe risk of resource leaks, that has implications for which pooling modes you can use. Particularly, you can't use statement-level pooling, and unless you're scrupulous about managing those implicitly created transactions, transaction-level pooling is pretty much the same thing as connection-level pooling.

Adjust your expectations accordingly, or turn on auto-commit.

(EDIT: clarification.)

Re:Fixing Database Connections in Django by zzzeek on Friday March 08, 2013 @05:12PM (#5346064)
the SQLAlchemy connection pool (which is what this is using) calls connection.rollback() when the connection is checked back in. as far as "leaking" transactional state it's not different from "autocommit", which is what Postgresql connections normally do (and what psycopg2 will do if you set `connection.autocommit=True`).
Re:Fixing Database Connections in Django by rosser on Friday March 08, 2013 @05:24PM (#5346143)
How is a connection "checked back in"?
Re:Fixing Database Connections in Django by zzzeek on Friday March 08, 2013 @05:58PM (#5346309)
the pool is transparent around acquisition and release:

    conn = pool.connect()
    conn.close()
the above "close()" is a release/checkin.