如何在 PostgreSQL 中设置排它锁的超时时间
我的导入脚本由于我设置脚本的“Exclusive nowait”选项而失败。这导致脚本第一次无法获得表上的排他锁时出错。我的脚本是这样实现的:
“现在在独占模式下锁定表%s”
现在我的脚本可以工作了,只是我希望能够为 PostgreSQL 设置超时,而不是让它等待最大时间 15 分钟。我更喜欢在 posgresql.conf 中设置它。有办法做到这一点吗?
I have an import script that was failing because of the 'Exclusive nowait' option I set my script. This caused the script to error out the first time it could not get the exclusive lock on the table. My script did it this way:
"LOCK TABLE %s IN EXCLUSIVE MODE NOWAIT"
Now my script works it's just that I want to be able to set the timeout for PostgreSQL instead of having it wait for the maximum time which is 15mins. I prefer to set it in posgresql.conf. Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该主题于 2010 年 8 月正在讨论,并且似乎恰好提供了您需要的 optin (lock_timeout) 的补丁即将被拒绝,因为它使 PG 中的超时框架变得非常复杂。所以我假设你必须在这里使用通常的statement_timeout。
This topic was under discussion in August 2010, and at seems the patch which provided exactly the optin you need (lock_timeout) is about to be rejected because it complicates the timeout framework in PG to much. So I assume you have to go with the usual statement_timeout here.