This project is archived and is in readonly mode.
Psycopg2 hung queries
Reported by Psycopg website | June 23rd, 2012 @ 02:44 PM
Submitted by: anoop
We have a python program which uses psycopg2 to make a connection every 2 seconds to postgresql-9.0 and batch insert/update records. The connection is closed after use.
It's part of a server software which run continuously for months. Some times the query processes is getting stuck (for ever) in pgWaitTimed.
But pg_stat_activity on postgresql indicates that no query is running.
StackTrace ----------- >> pqWaitTimed >> PQgetResult
The processes has to be restarted to fix the issue.
Comments and changes to this ticket
I'm seeing the exact same problem in a multithreaded Python application. It makes and drops connections rapidfire for a few minutes, then hangs. GDB indicates the hang is in psycopg2.
We have a 100% reproduceable test case for this on our test environment; let me know what you want to trace etc. in order to diagnose this.
- State changed from new to open
Josh, are you using the latest, 2.4.5? There have been a few multithread bug fixed in that version.
Anoop, from your tag I see you are using 2.4.1: can you try updating and repeat your test?
Josh, a stack trace would be a start. Are you creating one cursor per connection or many cursors? Is the same connection used by different threads from the different cursors? (which should work, but here is where a bug may lurk). Is the same cursor used by different threads? (which is not to be done).
It would be killer if you could synthesize your test case into something that you can provide us.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
WARNING: the informations in this tracker are archived. Please submit new tickets or comments to the new tracker.
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.