PostgreSQL进程被意外杀死

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lixiaogang_theanswer/article/details/85595908

设备在进行压力测试时候,当导入数据库表中数据达到约93W左右时候,进程就会被意外的 kill 掉。如图
在这里插入图片描述

终端除了提示某进程被 kill掉外,还会一直刷屏,并打印:

could not connect to server: Connection refused
	Is the server running on host "127.0.0.1" and accepting
	TCP/IP connections on port 5432?

could not connect to server: Connection refused
	Is the server running on host "127.0.0.1" and accepting
	TCP/IP connections on port 5432?

could not connect to server: Connection refused
	Is the server running on host "127.0.0.1" and accepting
	TCP/IP connections on port 5432?

could not connect to server: Connection refused
	Is the server running on host "127.0.0.1" and accepting
	TCP/IP connections on port 5432?
	
//省略若干打印..................................

1.首先排除代码问题(如段错误、内存泄漏等)因素,因为该代码已经成功运行并发布了许久,该次的压力测试只是将代码移植到另外一个项目分支中。
2. 考虑是否因为内存空间被占用完,而导致内存空间不足,从而被kill掉了。free查看了内存的空间大小为 8G。

在这里插入图片描述

使用命令ps -aux | sort -k4nr | head -n 10查看了当前系统中占用内存空间最多的10个进程,结果发现其中一个进程很不正常,内存占用已经是遥遥领先于其他进程。
在这里插入图片描述

好家伙,你一个进程就占用了3.1G的内存空间,而系统可用的内存总共就只有7.7G,因此这个进程肯定是有问题的。首先想到的一个就是内存泄漏,联系了该模块同事,最终排查的结果果真是该模块存在“内存泄漏”的严重问题。所以才导致PostgreSQL在每次导入数据在93W左右时候被自动 kill 掉,原因是内存空间被占用完了。




猜你喜欢

转载自blog.csdn.net/lixiaogang_theanswer/article/details/85595908