3

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?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
M.Mike
  • 663
  • 1
  • 6
  • 12
  • The problem must be in your code or in go or the driver it uses, because PostgreSQL complains that the number of parameters in your statement is different from the number of arguments supplied. Could it be different threads using the same connection with bad synchronization? – Laurenz Albe Jun 01 '17 at 08:35
  • I set the pool_mode = Session,the problem no longer happened.But I still confuse with the difference between Transaction and Session – M.Mike Jun 02 '17 at 01:47
  • It might be the problem that your code is not transaction-aware in terms of environment, as you are using _transaction_ mode in PgBouncer. The reason of that working on single thread is that you serialize the execution of the session. You can try pool_mode in _session_ mode to verify this theory. – 3manuek Aug 17 '18 at 16:30

1 Answers1

3

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

Logovskii Dmitrii
  • 2,629
  • 4
  • 27
  • 44