#9964: Transaction middleware closes the transaction only when it's marked as dirty ---------------------------------------------------+------------------------ Reporter: ishirav | Owner: mtredinnick Status: assigned | Milestone: 1.3 Component: Database layer (models, ORM) | Version: 1.0-beta-1 Resolution: | Keywords: transactions Stage: Accepted | Has_patch: 1 Needs_docs: 1 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Comment (by seanc):
I would argue that this is more than a simple cosmetic bug, and that fixing this has a huge set of benefits. A few additional notes: 1) PostgreSQL can't get rid of versions of tuples that are held inside of a read transaction (e.g. a VACUUM can't reap rows that have been read in a transaction until the transaction is closed) 2) Users of pgbouncer with their pool_mode set to 'transaction' aren't free'ing up the backend, which dramatically cuts the effectiveness of pgbouncer. {{{ ; When server connection is released back to pool: ; session - after client disconnects ; transaction - after transaction finishes ; statement - after statement finishes pool_mode = transaction }}} 3) Neither COMMIT or ROLLBACK will perform any better than the other. See the following thread for some small details. http://www.mail-archive.com/pgsql-gene...@postgresql.org/msg60957.html One important catch to keep in mind is that SELECT can call functions that modify tables. COMMITs will provide better "do what I expect" behavior, but I would argue that users of functions that modify data should be explicit in their COMMITs. Based on what I've read in the thread above, adding three new versions of the TransactionMiddleware appears to provide the easiest path forward. "TransactionMiddlewareRollback," "TransactionMiddlewareCommit," and "TransactionMiddlewareOpen". Copy TransactionMiddleware to TransactionMiddlewareOpen and have TransactionMiddleware issue a warning on startup that the developer should switch to Rollback or Commit (or Open to preserve the current buggy functionality). In a future version, change TransactionMiddleware to use TransactionMiddlewareRollback as the default or just remove it all together. I'd rather see an explicit behavior configured as a Middleware class vs. an entry in settings.py. -- Ticket URL: <http://code.djangoproject.com/ticket/9964#comment:22> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.