pgagroal
pgagroal copied to clipboard
Connections hang if the database limit max_size is overtaken
While inspecting #456 I found this behavior that applies also to master branch 40acff635d16e00eac08bf5307efdabc03ee13cd:
% pgagroal-cli conf get max_connections
15
% pgagroal-cli conf get limit.pgbench.max_size
12
% pgagroal-cli conf get limit.pgbench.min_size
5
so the system is allowing 15 max connections and 12 are possible at max against the pgbench
database.
Every run with a number of client less than 12 (pgbench max connections) works:
% time /usr/pgsql-16/bin/pgbench -c 5 -n -T 60 -h localhost -p 54322 -U pgbench pgbench
...
/usr/pgsql-16/bin/pgbench -c 5 -n -T 60 -h localhost -p 54322 -U pgbench 0.11s user 0.19s system 0% cpu 1:01.39 total
% time /usr/pgsql-16/bin/pgbench -c 10 -n -T 60 -h localhost -p 54322 -U pgbench pgbench
...
/usr/pgsql-16/bin/pgbench -c 10 -n -T 60 -h localhost -p 54322 -U pgbench 0.12s user 0.27s system 0% cpu 1:00.53 total
% time /usr/pgsql-16/bin/pgbench -c 12 -n -T 60 -h localhost -p 54322 -U pgbench pgbench
...
/usr/pgsql-16/bin/pgbench -c 12 -n -T 60 -h localhost -p 54322 -U pgbench 0.12s user 0.27s system 0% cpu 1:00.66 total
then when the number of clients is greater than max connections for the database, the system seems to hang the connections and the running never ends:
% time /usr/pgsql-16/bin/pgbench -c 13 -n -T 60 -h localhost -p 54322 -U pgbench pgbench
pgbench (16.4)
^C
/usr/pgsql-16/bin/pgbench -c 13 -n -T 60 -h localhost -p 54322 -U pgbench 0.00s user 0.01s system 0% cpu 1:07.47 total
% time /usr/pgsql-16/bin/pgbench -c 15 -n -T 60 -h localhost -p 54322 -U pgbench pgbench
pgbench (16.4)
^C
/usr/pgsql-16/bin/pgbench -c 15 -n -T 60 -h localhost -p 54322 -U pgbench 0.00s user 0.01s system 0% cpu 3:57.05 total
in the meantime, observing the status reports the connections to be in replica mode:
% pgagroal-cli status
Status: Running
Active connections: 12
Total connections: 13
Max connections: 15
[luca@rachel]~% pgagroal-cli status details
Status: Running
Active connections: 12
Total connections: 13
Max connections: 15
---------------------
Server: rachel
Host: 127.0.0.1
Port: 5432
State: Primary
---------------------
Database: pgbench
Username: pgbench
Active connections: 12
Max connections: 12
Initial connections: 5
Min connections: 5
---------------------
Database: testdb
Username: luca
Active connections: 0
Max connections: 2
Initial connections: 1
Min connections: 1
---------------------
Connection 1: Replica 2024-09-23 17:19:59 165147 15 pgbench pgbench pgbench
Connection 2: Replica 2024-09-23 17:19:59 165148 16 pgbench pgbench pgbench
Connection 3: Replica 2024-09-23 17:19:59 165149 17 pgbench pgbench pgbench
Connection 4: Replica 2024-09-23 17:19:59 165150 18 pgbench pgbench pgbench
Connection 5: Replica 2024-09-23 17:19:59 165151 19 pgbench pgbench pgbench
Connection 6: Primary 2024-09-23 17:19:58 20 luca testdb
Connection 7: Replica 2024-09-23 17:19:59 165152 5 pgbench pgbench pgbench
Connection 8: Replica 2024-09-23 17:19:59 165154 5 pgbench pgbench pgbench
Connection 9: Replica 2024-09-23 17:19:59 165156 5 pgbench pgbench pgbench
Connection 10: Replica 2024-09-23 17:19:59 165158 5 pgbench pgbench pgbench
Connection 11: Replica 2024-09-23 17:19:59 165160 5 pgbench pgbench pgbench
Connection 12: Replica 2024-09-23 17:19:59 165162 5 pgbench pgbench pgbench
Connection 13: Replica 2024-09-23 17:19:59 165164 5 pgbench pgbench pgbench
Connection 14: Not init
Connection 15: Not init