Search code examples
postgresqlpgbouncer

PgBouncer too many client connections for select()


I have created PostgreSql v12(port 5432) and pgbouncer v1.9(port 6432). Then I have created a new test database on the pgbouncer server. I followed these steps:

  1. pgbench -h localhost -p 6432 -U postgres -i -s 150 test
    

    it has created pgbench tables.

  2. pgbench -p 6432 -U postgres -c 200 -j 2 -P 60 -t 1000 -d test
    

    if i use -c 85 it will run without error. When i increase -c to more than 85 or 90 I'm getting too many client connections for select().

  3. I have configured pgbouncer.ini and postgresql.conf files. On pgbouncer I have added

    test = host=localhost port=5432 dbname=test & pool_mode = transaction,max_client_conn = 10000, default_pool_size = 20
    

    in postgresql.conf I increased max_connections from 100 to 1000 and shared_buffers from 128 to 256MB.

    PgBouncer.ini
    Cmd ss
    PgBouncer
    postgres.conf
    db

I would like to vacuum that database with more than 100 clients.


Solution

  • if i use -c 85 it will run without error. When i increase -c to more than 85 or 90 I'm getting too many client connections for select().

    The text "too many client connections for select()" occurs in pgbench client, and not in either postgresql server nor pgbouncer (that I can find, they might be pieced together from smaller strings). So whatever is going on is going on inside pgbench. But, it isn't clear what that actually is, as the command you show certainly should not need more than 1024 file descriptors.

    Why inject pgbouncer into this at all? If you want all connections open and in use simultaneously, pgbouncer has nothing to offer you. Do you get the same error if you point pgbench directly at the database?

    I would like to vacuum that database with more than 100 clients.

    Why?