django shell触发Postgres空闲事务问题
实际上,这不是 django (iPython) shell 的错。问题是打开 django shell ./manage.py shell
的开发人员运行一些查询(它通常只生成选择),然后要么让 shell 保持运行,要么以某种方式终止他们的 (ssh) 会话(实际上,我不确定后一种情况是否使事务保持打开状态 - 我还没有测试过)
无论如何,nagios 都会定期对这些空闲事务发出警报。当然,我们可以调用 developer.stop_doing_that_dammit()
但它不可靠。
我正在寻找解决此问题的想法,允许开发人员使用 django shell,但如果他们忘记关闭会话,则关闭事务。
It's not the fault of the django (iPython) shell, actually. The problem is developers who open the django shell ./manage.py shell
run through some queries (it often only generates selects), and then either leave the shell running or somehow kill their (ssh) session (actually, I'm not sure if the latter case leaves the transaction open - I haven't tested it)
In any case, nagios regularly alerts over these idle transactions. We could, of course call developer.stop_doing_that_dammit()
but it's unreliable.
I'm looking for thoughts on resolving this in a way that allows developers to use the django shell, but closes transactions should they forget to close their session out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以始终运行一个 cron 作业,该作业将在数据库内调用 pg_cancel_backend(),对于空闲时间超过 1 天的后端(当然这取决于 nagios 设置)。
You may always run a cron job, that will call pg_cancel_backend() within the database, for the backends that are idle for longer than e.g. 1 day (of course that depends on the nagios settings).