Hey ! I have been using using WebFaction for a few months to host a Django project hooked to a PostgreSQL via Psycopg2.

I tried to replicate my production configuration on my local dev machine but just hit a wall:

Everything is working fine but postgreSQL is keeping all my non-modifying database queries opened ("idle in transaction"). So I get dozen of idle transactions really quickly.

I made some searches and apparently Django/psycopg2 is making a transaction for every query but is not making the commit/rollback for "SELECT only".

What's boggling me is that in production on WebFaction there is apparently no such problem. I found different fixes online but they looked a bit dirty.

I was wondering what technique is used on WebFaction or if my question is irrelevant.

Thanks.

asked 13 Feb '12, 18:40

Hindo's gravatar image

Hindo
12
accept rate: 0%

edited 14 Feb '12, 03:37


Are you using the exact same versions of Django, Postgres and Psycopg2 locally? Normally issues with the Django ORM mechanics is due to an outdated version of Django or another library in the ORM stack.

link

answered 13 Feb '12, 19:33

johns's gravatar image

johns ♦♦
4.1k28
accept rate: 23%

I checked the version numbers and I'm actually a bit forward.

PostgreSQL is 9.1.2 on dev and 8.3.11 in prod

Psycopg2 is 2.4.4 on dev and 2.3.2 in prod.

Django is the same.

(13 Feb '12, 21:26) Hindo Hindo's gravatar image

I have found many bugs referencing this like the one here. What version of Django are you using? the bug reports seem to indicate this is patched in the most recent versions.

(13 Feb '12, 22:09) johns ♦♦ johns's gravatar image

1.3.1, the same version as webfaction. I found this ticket too (and one or two posts about that on stackoverflow). Sorry I should have linked them. Most fixes sound dirty, and I'm not ready to switch to the 1.4. So I'm just trying to understand how webfaction does to avoid/cancel those idle transactions.

(13 Feb '12, 23:46) Hindo Hindo's gravatar image

To be honest I have never seen this exact issue on our platform, however we force timeouts on all queries so that may be why. Searching our support ticket histories for similar cases shows nothing conclusive. Maybe try setting statement_timeout to a low value.

(14 Feb '12, 00:17) johns ♦♦ johns's gravatar image

I miss diagnosed my issue. I had a blocking call in a Django view creating those idle transactions.

Sorry that I wasted your time and thanks for your help

link

answered 14 Feb '12, 03:37

Hindo's gravatar image

Hindo
12
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×742
×84

Asked: 13 Feb '12, 18:40

Seen: 1,189 times

Last updated: 14 Feb '12, 03:37

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited