kill -9 a postgres process
在postgresql中,不推荐使用Kill -9直接杀掉异常连接,因为直接使用kill -9会引起整个数据库核心进程的重启,同时其他正常程序连接也会被杀掉。
现开启两个psql连接,然后使用Kill -9杀掉其中一个:
session1: swrd=# select pg_backend_pid();
pg_backend_pid
----------------
26965
(1 row) swrd=# select pg_backend_pid();
WARNING: terminating connection because of crash of another server process
DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit,
because another server process exited abnormally and possibly corrupted shared memory.
HINT: In a moment you should be able to reconnect to the database and repeat your command.
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
swrd=# select pg_backend_pid();
pg_backend_pid
----------------
833
(1 row)
session2: postgres=# select pg_backend_pid();
pg_backend_pid
----------------
25975
(1 row) postgres=# select pg_backend_pid();
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
postgres=# select pg_backend_pid();
pg_backend_pid
----------------
835
(1 row)
观察上面的日志信息,可以看到session2是被杀掉的会话,但同时session1也被杀掉了。
下面是有关postgre的进程信息,发现除了守护进程和logger进程外,其他进程都重启了。
[root@db~]# ps auxwwf |grep postgres
root 0.0 0.0 pts/ S : : | \_ su - postgres
postgres 0.0 0.0 pts/ S : : | \_ -bash
postgres 0.0 0.0 pts/ S+ : : | \_ psql
root 0.0 0.0 pts/ S : : | \_ su - postgres
postgres 0.0 0.0 pts/ S : : | \_ -bash
postgres 0.0 0.0 pts/ S+ : : | \_ psql
root 0.0 0.0 pts/ S+ : : \_ grep postgres
postgres 0.0 0.0 ? S : /opt/pg96/bin/postgres
postgres 0.0 0.0 ? Ss : \_ postgres: logger process
postgres 0.0 0.0 ? Ss : : \_ postgres: checkpointer process
postgres 0.0 0.0 ? Ss : : \_ postgres: writer process
postgres 0.0 0.0 ? Ss : : \_ postgres: wal writer process
postgres 0.0 0.0 ? Ss : : \_ postgres: autovacuum launcher process
postgres 0.0 0.0 ? Ss : : \_ postgres: archiver process
postgres 0.0 0.0 ? Ss : : \_ postgres: stats collector process
postgres 0.0 0.0 ? Ss : : \_ postgres: postgres postgres [local] idle
postgres 0.0 0.0 ? Ss : : \_ postgres: swrd swrd [local] idle
[root@db~]# kill -
[root@db~]# ps auxwwf |grep postgres
root 0.0 0.0 pts/ S : : | \_ su - postgres
postgres 0.0 0.0 pts/ S : : | \_ -bash
postgres 0.0 0.0 pts/ S+ : : | \_ psql
root 0.0 0.0 pts/ S : : | \_ su - postgres
postgres 0.0 0.0 pts/ S : : | \_ -bash
postgres 0.0 0.0 pts/ S+ : : | \_ psql
root 0.0 0.0 pts/ S+ : : \_ grep postgres
postgres 0.0 0.0 ? S : /opt/pg96/bin/postgres
postgres 0.0 0.0 ? Ss : \_ postgres: logger process
postgres 0.0 0.0 ? Ss : : \_ postgres: checkpointer process
postgres 0.0 0.0 ? Ss : : \_ postgres: writer process
postgres 0.0 0.0 ? Ss : : \_ postgres: wal writer process
postgres 0.0 0.0 ? Ss : : \_ postgres: autovacuum launcher process
postgres 0.0 0.0 ? Ss : : \_ postgres: archiver process
postgres 0.0 0.0 ? Ss : : \_ postgres: stats collector process
postgres之所以这么做是因为使用kill -9杀掉的进程,是没有机会做好清理工作的,因为kill -9是SIGKILL信号,程序不属于正常退出,杀掉的进程可能由于正在进行写入或修改的操作,从而造成内存页的损坏,为了保证数据库的正常故会重启内部进程。
如果不使用kill -9,而使用普通的kill操作是不会引起postgres内部进程的重启的。对于中断操作或杀掉会话,建议使用pg自带的pg_cancel_backend()和pg_terminate_backend()。
参考:
https://serverfault.com/questions/415188/kill-9-a-postgres-process
kill -9 a postgres process的更多相关文章
- kill tomcat process in window
1.通过命令netstat -ano | findstr 8080找到tomcat所占用的process,如下图 2.执行ntsd -c q -p 7944 kill刚刚找到的process,然后 ...
- mysql kill process解决死锁
mysql使用myisam的时候锁表比较多,尤其有慢查询的时候,造成死锁.这时需要手动kill掉locked的process.使他释放. (以前我都是重起服务)..惭愧啊.. 演示:(id 7是我用p ...
- Process Node.js 进程
Process 进程 process.argv 是命令行参数数组,第一个元素是node,第二个元素是脚本文件名,从第三个元素开始每个元素是一个运行参数. process.stdout 标准输出流 co ...
- A discussion of Dead Connection Detection, Resource Limits, V$SESSION, V$PROCESS and OS processes
A discussion of Dead Connection Detection, Resource Limits, V$SESSION, V$PROCESS and OS processes (文 ...
- System.Diagnostics.Process 测试案例
1.System.Diagnostics.Process 执行exe文件 创建项目,编译成功后,然后把要运行的exe文件拷贝到该项目的运行工作目录下即可,代码如下: using System; usi ...
- kill、killall、pkill杀手三人组
1.1 kill.killall.pkill杀手三人组 1.利用kill 进程号 方式杀掉rsync进程 [root@backup ~]# ps -ef |grep rsync root 3500 1 ...
- check process id exists
kill -0 pid sending the signal 0 to a given PID just checks if any process with the given PID is run ...
- Linux kill/pkill/killall命令详解
kill kill(terminate a process)命令用来终止指定的进程, 对于一个后台进程就须用kill命令来终止,我们就需要先使用ps/pidof/pstree/top等工具获取进程PI ...
- jenkins Process leaked file descriptors
https://stackoverflow.com/questions/17024441/process-leaked-file-descriptors-error-on-jenkins 1. BUI ...
随机推荐
- PHASER3 设置场景SCENE SLEEPING休眠和WAKE唤醒
A good way to set scene stop when hidden and run while visible again ! 使用sleep和wake方法的好处: 1.可以彻底让sce ...
- vue cli 3 +jquery
const webpack = require('webpack')module.exports = { // baseUrl type:{string} default:'/' // 将部署应用程序 ...
- idea compare功能 之一次bug修复
一次bug修复 最近开发完了一套单点系统,jenkins打包上传到服务器就出问题, 可以启动但是不能正常工作. 首先想到的是环境不一样, 于是把jenkins的jdk和maven都调整和本机大版本相同 ...
- mysql 5.5 zip配置安装
1.解压2.创建option文件 --defaults-file=../my.ini [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mys ...
- 互评Alpha版本——二次元梦之队——“I Do”
基于NABCD评论作品,及改进建议 1.根据(不限于)NABCD评论作品的选题 (1)N(Need,需求) 随着智能科技的发展和普及,编程教育的重要性已经逐渐凸显出来.美国前总统奥巴马曾说“编程应当与 ...
- C/C++学习计划
学习内容:C语言程序设计精髓/计算机程序设计(C++) 学习理由:基础比较薄弱,想先打好基础. 时间安排:每天学习两课时. mooc地址:http://www.icourse163.org/home. ...
- Codeforces Round #312 (Div. 2) E. A Simple Task 线段树+计数排序
题目链接: http://codeforces.com/problemset/problem/558/E E. A Simple Task time limit per test5 secondsme ...
- CentOS7实现RabbitMQ高可用集群
CentOS安装RabbitMQ集群 1.有3台已安装RabbitMQ的机器 192.168.38.133 rabbitmq1 192.168.38.137 rabbitmq2 192.168.38. ...
- IBM存储降级告警等一些服务器问题/dd/ethtool
1.IBM存储降级告警 一般两种情况 a.端口降级 例如模块16G->8G(IBM储存端口自适应) b.系统在作raid后,有硬盘损坏,降级 黄灯告警 2. dimm error dimm内存插 ...
- <问吧>调查问卷心得体会
<问吧>调查问卷心得与体会 在这之前,我们已经组成了一个六个人的小团队---“走廊奔跑队”,我们这次做的这个项目的名称是:问吧.在项目实施之前,我们必做的一步就是需求分析,目的就是充分了解 ...