高并发pgbench测试报错:Resource temporarily unavailable

6370阅读 0评论2015-01-20 skykiker
分类:Mysql/postgreSQL

在CentOS 6.5 + PostgreSQL 9.3.4下运行一个高并发的pgbench测试,发现并发数超过一定数量(max_connections已经设成足够大了)的时候,执行会出错。

命令:
pgbench -n -r -c 250 -j 250 -T 2 -f update_smallrange.sql


错误消息:
Connection to database "" failed:
could not connect to server: Resource temporarily unavailable
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5433"?


但是从上面的“Resource temporarily unavailable”看不出是哪个资源出问题了。
经过调查,找到了下面一个链接


原来是PG服务端的listen backlog(受内核参数somaxconn限制)不够用了,somaxconn的默认值是128,调大后,重启PG再测就OK了。

echo 256 > /proc/sys/net/core/somaxconn
上一篇:PostgreSQL中1000分区的继承分区表更新失败的原因
下一篇:PostgreSQL高并发单行更新发生死锁