PostgreSQL连接池pgbouncer程序连接报错解决一例

前端之家收集整理的这篇文章主要介绍了PostgreSQL连接池pgbouncer程序连接报错解决一例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
昨晚对一个应用做了模拟压测,用最新版pgbouncer时发现了一些问题。

底层环境:
OS:CentOS 6
DB:Postgres 9.1.2
Pool:pgbouncer 1.5.4

pgbouncer的配置脚本:
[root@kenyon config]# more pgbouncer.ini 
[databases]
db_kenyon = host=172.65.20.35 port=2949 dbname=db_kenyon   
openfire = host=172.65.20.35 port=2949 dbname=openfire

[pgbouncer]
listen_port = 5432 
listen_addr = 172.65.20.35
auth_type = md5 
auth_file = /home/postgres/pgbouncer/config/user.txt
logfile = /home/postgres/pgbouncer/pgbouncer.log
pidfile = /home/postgres/pgbouncer/pgbouncer.pid
admin_users = u_kenyon
pool_mode = Transaction
max_client_conn = 1500
user.txt的配置脚本
[root@kenyon config]# more user.txt 
"u_test" "md53173bce1d3101d6659vceb49d7eb3f2d"
"u_kenyon" "md53173bce1d3101d6659vceb49d7eb3f2d"
启动连接时是正常的,但是程序压测开始后数据并没有生成,查看日志,有异常内容如下:
2012-12-11 19:36:14.870 19072 WARNING C-0x3620a20: (nodb)/(nouser)@172.65.20.35:55418 unsupported startup parameter: extra_float_digits=2
2012-12-11 19:36:14.870 19072 LOG C-0x3620a20: (nodb)/(nouser)@172.65.20.35:55418 closing because: Unsupported startup parameter: extra_float_digits (age=0)
2012-12-11 19:36:14.870 19072 WARNING C-0x3620a20: (nodb)/(nouser)@172.65.20.35:55418 Pooler Error: Unsupported startup parameter: extra_float_digits
2012-12-11 19:36:44.881 19072 WARNING C-0x3620a20: (nodb)/(nouser)@172.65.20.35:55419 unsupported startup parameter: extra_float_digits=2
2012-12-11 19:36:44.881 19072 LOG C-0x3620a20: (nodb)/(nouser)@172.65.20.35:55419 closing because: Unsupported startup parameter: extra_float_digits (age=0)
2012-12-11 19:36:44.881 19072 WARNING C-0x3620a20: (nodb)/(nouser)@172.65.20.35:55419 Pooler Error: Unsupported startup parameter: extra_float_digits
报错很明显,有一个参数不支持unsupported startup parameter extra_float_digits ,pgbouncer中有一个参数是可以忽略启动参数的,叫ignore_startup_parameters

处理办法:
修改配置文件pgbouncer.ini,在[pgbouncer]下面新增一行
ignore_startup_parameters = extra_float_digits
重启pgbouncer,再次查看日志,该参数已被忽略,测试数据正常。

其他:

程序有可能也有其他参数会导致pgbpuncer异常,比如geqo等,忽略多个参数时,以逗号分隔即可,比如: ignore_startup_parameters = extra_float_digits,geqo

源码中的定义:char *cf_ignore_startup_params = "";

参考:http://archives.postgresql.org/pgsql-committers/2008-04/msg00101.php

顺带说一句,用了pgbouncer,实际连到DB的进程数大大减少,平均下来有20个左右。没有启用pgbouncer做压测的时候,默认的100个最大连接数是不够用的。

原文链接:https://www.f2er.com/postgresql/196335.html

猜你在找的Postgre SQL相关文章