login community faq

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 Feb 13 '12 at 18:40

Hindo's gravatar image

Hindo
11

edited Feb 14 '12 at 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.

answered Feb 13 '12 at 19:33

johns's gravatar image

johns ♦♦
345427

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.

(Feb 13 '12 at 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.

(Feb 13 '12 at 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.

(Feb 13 '12 at 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.

(Feb 14 '12 at 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

answered Feb 14 '12 at 03:37

Hindo's gravatar image

Hindo
11

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

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