我有一个使用Postgres 9.3的Java Web应用程序。每当Web服务器启动时,它都会使用以下查询获取数据库锁定:
leads
但是当我停止服务器时,它不会释放它先前获得的排他锁。
select pg_try_advisory_lock(100);
oneproduct是Java应用程序使用的数据库(已锁定)
据我所知,当Postgres的客户停止或杀死或死亡时,所有的锁都被释放了,如果我错了,请纠正我。
当我检查此PID 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)
时,它处于睡眠状态,但其对等方已经死了。
为什么这种行为? 请解释一下,我有什么遗漏吗?