Saturday, June 9, 2012

Killing idle sessions in Postgresql

Recently, i faced an issue with Postgresql with one table where it got locked due to some reason. I followed below steps to unlock it ::

1) connect to Postgresql using below command

ssh -L 5432:127.0.0.1:5432 DEMO@server.com

2) Find idle processes using below command

ps -ef | grep postgres

Identify the process and note its id

3) connect to database using PG Admin tool

Fire below command from sql window

pg_cancel_backend(‘procpid’) 

Thanks,

Ujjwal Soni

No comments: