Patryk Zawadzki skrev 2010-09-06 15.29:
On Mon, Sep 6, 2010 at 2:00 PM, Robert Gravsjö<rob...@blogg.se>  wrote:
I'm not sure what you think you are doing but if you end up with "<IDLE>
  in transaction" that means you have not commited your transactions.

See below.

For instance, open two connections with psql and run BEGIN in one and
then take a look at pg_stat_activity you will have that connection
marked as idle in transaction.

I believe you are confused about isolation levels. They control the
visibility of transactions.

Maybe I am indeed confused but quoting the psycopg documentation¹:

"psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED:

This is the default value. A new transaction is started at the first
execute() command on a cursor and at each new execute() after a
commit() or a rollback(). The transaction runs in the PostgreSQL READ
COMMITTED isolation level."

The isolating transaction keeps going on until you either (1) commit,
(2) rollback or (3) disconnect. Django only commits/rollbacks the
transactions it explicitly starts, it does not care about the
implicitly started isolating transaction. That's what results in
"<IDLE>  in transaction" and I can reproduce it with a two-line view
that does a simple SELECT with no transaction middleware involved.

Can you please show me the code you're running to reproduce this?

Regards,
roppert


The problem only exists when Django sets isolation level to 1, if you
use the deprecated "autocommit" setting, you will not be affected.

¹ http://initd.org/psycopg/docs/extensions.html#isolation-level-constants


--
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to