加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql中的pg_cancel_backend

发布时间:2020-12-13 17:53:38 所属栏目:百科 来源:网络整理
导读:postgresql 中的一些定义,如下: pg_cancel_backend and pg_terminate_backend send signals ( SIGINT or SIGTERM respectively) to backend processes identified by process ID. The process ID of an active backend can be found from the procpid colu

postgresql 中的一些定义,如下:

pg_cancel_backend and pg_terminate_backend send signals (SIGINT or SIGTERM respectively) to backend processes identified by process ID. The process ID of an active backend can be found from the procpid column of the pg_stat_activity view,or by listing the postgres processes on the server (using ps on Unix or the Task Manager on Windows ).

两者都是boolean 类型的,返回为true 或者false

pg_cancel_backend 用来取消一个进程

首先通过pg_stat_activity 查出你要取消的进程号

select procpid from pg_stat_activity where ......;

然后,用这个函数来取消

select pg_cancel_backend(procpid);

这个函数主要是取消某个进程,但是某个会话并不会因此而被强制退出

在实际场景中经常碰到一些比较复杂的查询,跑了很久跑不出来,使用这个函数也不起作用,去OS 直接killkill 不掉,就只有重启集群了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读