Take the 2-minute tour ×

we have this super weird issue happening with postgres that only happens on random requests. We get an InterfaceError: connection already closed which seems to be being thrown by the TransactionMiddleware. This was causing random 500 pages for the end-user.

Removing TransactionMiddleware seems to solve all our issues however I am quite scared about what this might actually do. If you remove TransactionMiddleware will it in anyway endanger data integrity via dirty reads/writes or cause any other issues?

I have googled high and low to try and figure out why TransactionMiddleware is throwing this error but nothing seems too relevant.



share|improve this question
I don't know the direct answer to your question, but I should say that the whole Django 1.5 transaction scheme is questionable and thus it's been replaced entirely in 1.6. 1.6 transactions are/will be much better. –  Andrew Gorcester Apr 16 '13 at 6:43
Obvious question about your situation - do you have some middleware that accesses database after transaction is closed? tracebacks and other technical information would be useful, for understand the situation. Is this bug in django already tracker? –  singer Apr 16 '13 at 7:05
Thanks @singer. I will double check if any middleware does anything db related but I dont belive it does. –  Mike Casey Apr 17 '13 at 0:41
@AndrewGorcester thanks, yeah it looks way better. Can you get by without using it in 1.5? Not using it solved all our 500s but I am really nervous about data integrity now –  Mike Casey Apr 17 '13 at 0:42
I'm afraid I don't know. I am using 1.5 with transaction middleware and Postgres and we have not had trouble (though our app is still development and we have not stress-tested it yet). I'm interested in your problem but I don't have any insight. Sorry! –  Andrew Gorcester Apr 17 '13 at 5:17

Your Answer



Browse other questions tagged or ask your own question.