PostgreSQL transaction locked database table: "idle in transaction" I have a web application interacting with PostgreSQL (v8.4 &amp; Centos Linux) which suddenly started locking some of the database's tables. Still have no idea what happened, since the code is not new, has been running several time and has been tested beforehand.

I am trying to see what transaction might have cause it, or if a combination of it with an autovacuum process could have caused it. But in the meantime I would like to unlock the database tables. I tried restarting the postgreSQL service, terminating thus the processes in "idle in transaction" state which were locking the tables but it didn't work: next time my application performed the same call the tables went locked again. 

Any ideas on what can I do to unlock the database gracefully?
What you are seeing are transactions which are running, holding locks, and not doing anything.  What you need to do is trace the transactions back to their source and find out what they are doing.  They may be other admins who have logged in and forgot to log out.

In general it is usually a bad thing to hold transactions open and idle for a long time due to this sort of locking problem.