Anu
Anu

Reputation: 177

Deadlock in Postgres

I got deadlock while performing several queries parallely in pgsql. It throws the exception as

  Detail: Process 6656 waits for ShareLock on transaction 609600; blocked by process 8616.
  Process 8616 waits for ShareLock on transaction 609603; blocked by process 6656.
  Hint: See server log for query details. 

Here how can I find which process (query) is 6656?

Upvotes: 0

Views: 442

Answers (1)

KIM
KIM

Reputation: 1254

In case your pgsql version >= 9.2, the locking query would be there

select * from pg_stat_activity where pid=6656

In case your pgsql version < 9.2, the locking query would not be there

select * from pg_stat_activity where procpid=6656

In order to kill the process

select pg_terminate_backend(pid_to_kill);

or

select pg_cancel_backend(pid_to_cancel);

I'd rather recommend that you do pg_cancel_backend instead of pg_terminate_backend as the first choice if you are using PGPOOL.

Upvotes: 1

Related Questions