|
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. |
|
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. 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. 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. 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. 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. |
|
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 |