【发布时间】:2016-12-07 13:26:51
【问题描述】:
我有一个实现会话级咨询锁定的后端应用程序。但是,如果客户端突然失去连接(例如在连接时强制重新启动),咨询锁将保持在那里并且不会消失。
有没有办法让锁在连接断开后总是过期?
谢谢。
【问题讨论】:
-
While a flag stored in a table could be used for the same purpose, advisory locks are faster, avoid table bloat, and are automatically cleaned up by the server at the end of the session.postgresql.org/docs/9.1/static/explicit-locking.html 所以只要你的连接超时就可以了。