Skip to content

idle_transaction_timeout affects transactions which are not actually idle in transaction given time #125

@alexius2

Description

@alexius2

Sometimes pgbouncer close transaction because of idle_transaction_timeout when it shouldn't. i.e. application run some slow queries (duration of query could be larger than timeout) one after another without significant delay between them (confirmed by logs).

steps to reproduce:

  1. set idle_transaction_timeout = 1 in config, reload.
  2. create file with simple transaction:
    cat ~/test-idle.sql
    begin;
    select pg_sleep(1);
    select pg_sleep(2);
    rollback;
  3. make sure you are able to connect to some db via pgbouncer without password (add password to ~/.pgpass for example) and run

for i in {1..1000}; do psql -p 6432 -h 127.0.0.1 -U postgres -f ~/test-idle.sql || break; done 1>/dev/null

  1. wait until you see error messages like this:
    psql:/var/lib/pgsql/test-idle.sql:2: ERROR: idle transaction timeout
    psql:/var/lib/pgsql/test-idle.sql:3: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
    psql:/var/lib/pgsql/test-idle.sql:3: connection to server was lost

it could take several minutes. script will stop after error.

reproduced with pgbouncer 1.7.2 at centos 7.2.1511. I guess problem is somewhere in these lines:

age = now - server->link->request_time;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions