pgbouncer错误:关闭原因:客户端意外的EOF(age=0)

huangapple go评论68阅读模式
英文:

pgbouncer error: closing because: client unexpected eof (age=0)

问题

我的项目是用golang编写的,我使用PostgreSQL数据库,并使用pgbouncer作为数据库连接池。在完成基本功能后,我进行了一次压力测试。

在只有一个并发的情况下,通过以下命令进行测试,运行良好:

ab -n 1000 -c 1 -p '/home/mwh/postfile.txt' -T 'application/x-www-form-urlencoded' 'http://192.168.1.229:8090/hwSdk/tsk/get_t_k.json'

但是当我增加并发量时,通过以下命令进行测试:

ab -n 10000 -c 100 -p '/home/mwh/postfile.txt1 -T 'application/x-www-form-urlencoded' 'http://192.168.1.229:8090/hwSdk/tsk/get_t_k.json'

在应用程序日志中出现了与数据库查询相关的错误:

[2017-06-01 12:04:00] (pq: bind message supplies 18 parameters, but prepared statement "" requires 6)
[2017-06-01 12:04:00] (pq: bind message supplies 19 parameters, but prepared statement "" requires 3)

在pgbouncer.log文件中:

8035 2017-06-01 12:04:01.702 45619 LOG C-0xf9a4c0: cygnus/cygnus@192.168.1.229:40397 closing because: client close request (age=0)
8036 2017-06-01 12:04:01.703 45619 LOG C-0xf8b9f0: cygnus/cygnus@192.168.1.229:40406 closing because: client close request (age=0)
8037 2017-06-01 12:04:01.703 45619 LOG C-0xf8b248: cygnus/cygnus@192.168.1.229:40574 login attempt: db=cygnus user=cygnus tls=no
8038 2017-06-01 12:04:01.703 45619 LOG C-0xf8c198: cygnus/cygnus@192.168.1.229:40468 closing because: client close request (age=0)
8039 2017-06-01 12:04:01.703 45619 LOG C-0xfac6f0: cygnus/cygnus@192.168.1.229:40504 closing because: client close request (age=0)
8040 2017-06-01 12:04:01.707 45619 LOG C-0xf9e698: cygnus/cygnus@192.168.1.229:40235 closing because: client unexpected eof (age=0)

我的pgbouncer.ini配置如下:

pool_mode = Transaction
listen_port = 6543
listen_addr = *
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
logfile = /tmp/pgbouncer.log
pidfile = /tmp/pgbouncer.pid
stats_users = readonly,cygnus
max_client_conn = 2000
default_pool_size = 400
ignore_startup_parameters = extra_float_digits

问题是什么?

英文:

My project is written with golang,I use postgresql Database and use pgbouncer as a database pool connection. I did a pressure test after I finished the basic function.

It runs well as test by the command(just 1 concurrency):

ab -n 1000 -c 1 -p '/home/mwh/postfile.txt' -T 'application/x-www-form-urlencoded' 'http://192.168.1.229:8090/hwSdk/tsk/get_t_k.json'

But when I
increase the concurrency:

ab -n 10000 -c 100 -p '/home/mwh/postfile.txt1 -T 'application/x-www-form-urlencoded' 'http://192.168.1.229:8090/hwSdk/tsk/get_t_k.json'

something happened error with database query in the app log:

[2017-06-01 12:04:00]  (pq: bind message supplies 18 parameters, but prepared statement "" requires6) 
[2017-06-01 12:04:00]  (pq: bind message supplies 19 parameters, but prepared statement "" requires 3) 

In the pgbouncer.log file

8035 2017-06-01 12:04:01.702 45619 LOG C-0xf9a4c0: cygnus/cygnus@192.168.1.229:40397 closing because: client close request (age=0)
8036 2017-06-01 12:04:01.703 45619 LOG C-0xf8b9f0: cygnus/cygnus@192.168.1.229:40406 closing because: client close request (age=0)
8037 2017-06-01 12:04:01.703 45619 LOG C-0xf8b248: cygnus/cygnus@192.168.1.229:40574 login attempt: db=cygnus user=cygnus tls=no
8038 2017-06-01 12:04:01.703 45619 LOG C-0xf8c198: cygnus/cygnus@192.168.1.229:40468 closing because: client close request (age=0
8039 2017-06-01 12:04:01.703 45619 LOG C-0xfac6f0: cygnus/cygnus@192.168.1.229:40504 closing because: client close request (age=0)
8040 2017-06-01 12:04:01.707 45619 LOG C-0xf9e698: cygnus/cygnus@192.168.1.229:40235 closing because: client unexpected eof (age=0)

my pgbouncer.ini settings:

pool_mode = Transaction
listen_port = 6543
listen_addr = *
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
logfile = /tmp/pgbouncer.log
pidfile = /tmp/pgbouncer.pid
stats_users = readonly,cygnus
max_client_conn = 2000
default_pool_size = 400
ignore_startup_parameters = extra_float_digits

what's the problem?

答案1

得分: 3

如果您在PgBouncer中使用事务模式,您需要将binary_parameters=yes设置为您的数据库DSN连接中的参数。
postgres://user:pass@host:post/db_name?binary_parameters=yes

英文:

If you're using transaction mode in PgBouncer you have to set binary_parameters=yes to your database dsn connection
postgres://user:pass@host:post/db_name?binary_parameters=yes

huangapple
  • 本文由 发表于 2017年6月1日 13:00:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/44298848.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定