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 ...
随机推荐
- linux ——使用find如何快速替换所有相同参数
在生成环境上有时候需要大规模修改某一配置里的参数,但是该参数存在多个地方,比如IP地址 端口 项目名等,特别是项目名称混乱想统一 find /项目地址 -type f |xargs grep &qu ...
- win7重装系统后设置Python2.7环境
起因 台式机的主板莫名出现问题,显示器画面卡顿不能动,鼠标键盘无反应,在这种情况下只好按住电源键断电.下面重启后,显示器无画面,猜测开机后没有进BIOS.然后就拆机箱,拔下电源线后撬起主板电池几秒再放 ...
- python打印图形大全(详解)
,): shixin=chr() print(shixin) -------------------结果:2) for i in range(0,10): shixin=chr(9679) print ...
- Thunder团队Final周贡献分分配结果
小组名称:Thunder 项目名称:爱阅app 组长:王航 成员:李传康.翟宇豪.邹双黛.苗威.宋雨.胡佑蓉.杨梓瑞 分配规则 则1:基础分,拿出总分的20%(8分)进行均分,剩下的80%(32分)用 ...
- Android开发第二阶段(3)
今天:对闹钟代码的按钮事件进行了添加和修改.对监听器的相关应用也有了进一步的了解和深入. 明天:对主界面的代码的优化比如对按钮位置的调节等细节处理.
- 【二分图匹配】Plug It In!
http://codeforces.com/gym/101873 F 先对原图跑一遍匈牙利得到原始最大匹配,再遍历每个出度>1的点,考虑若新加入点,能否找到增广路,若可行则答案对应增加 代码: ...
- CodeForces 508E Arthur and Brackets 贪心
题目: E. Arthur and Brackets time limit per test 2 seconds memory limit per test 128 megabytes input s ...
- 《我是IT小小鸟》读后感
<我是IT小小鸟>读后感 说实话,我根本不喜欢看这本书,要不是因为老师要求我也不会去看的,其实当老师提起这本书的时候我还是有点兴趣,去看的,可是看了很多后,觉得这根本不适合我,里面说的都是 ...
- erlang init:stop()不起效
http://blog.equanimity.nl/blog/2015/03/15/erlang-one-weird-trick-goodiebag/ http://erlang.org/piperm ...
- Spark Shuffle之Sort Shuffle
源文件放在github,随着理解的深入,不断更新,如有谬误之处,欢迎指正.原文链接https://github.com/jacksu/utils4s/blob/master/spark-knowled ...