Postgres does not stop connection even after client is dead

Viewed 416

I have a java web application which uses Postgres 9.3. Whenever the web server starts it takes a database lock using the following query:

select pg_try_advisory_lock(100);

But when I stop the server it does not release Exclusive lock it gained earlier.

  postgres=# SELECT pl.pid,datname,mode, state FROM pg_locks pl LEFT JOIN pg_stat_activity psa  ON pl.pid = psa.pid;
  pid  |       datname        |      mode       | state  
-------+----------------------+-----------------+--------
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | ExclusiveLock   | active
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | AccessShareLock | active
  5217 | postgres             | AccessShareLock | active
 27669 | oneproduct           | ExclusiveLock   | idle
(10 rows)

oneproduct is the database that java app uses(it took the lock on)

To my knowledge When a client of Postgres stops or kill or dies all the Locks are released, correct me if I am wrong.

when I check this PID 27669 it is in the sleeping state but its peer is already dead.

Why this behaviour? please explain, am I Missing something?

0 Answers
Related