Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add new custom event loop for Linux I/O layer #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

decarv
Copy link
Contributor

@decarv decarv commented Aug 14, 2024

Introduce ev.h and ev.c, establishing the
foundation for the new custom event loop,
pgagroal_ev.

Replace previous dependencies on libev with the
custom event loop.

Implement support for io_uring with a fallback to
epoll if io_uring is unavailable.

CMakeLists.txt Outdated Show resolved Hide resolved
scripts/build.sh Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
@jesperpedersen
Copy link
Collaborator

@decarv Rebase, squash, and CI

@decarv decarv force-pushed the new-linux-io-layer branch from 24680d8 to 45da25d Compare August 19, 2024 02:57
@jesperpedersen
Copy link
Collaborator

https://github.com/pgmoneta/pgmoneta/tree/main/test

@decarv decarv force-pushed the new-linux-io-layer branch from 45da25d to 87204f9 Compare August 24, 2024 00:07
@jesperpedersen
Copy link
Collaborator

@decarv Please, look at the CI

@jesperpedersen
Copy link
Collaborator

Please, see if you can get the liburing version check in place as well

@decarv decarv marked this pull request as draft August 25, 2024 03:31
@decarv decarv force-pushed the new-linux-io-layer branch 2 times, most recently from f57a6f3 to 4a8a32c Compare September 8, 2024 19:08
src/libpgagroal/ev.c Outdated Show resolved Hide resolved
src/libpgagroal/ev.c Outdated Show resolved Hide resolved
@jesperpedersen
Copy link
Collaborator

Run sudo mkdir -p /etc/pgagroal
kernel.io_uring_disabled = 0
pgagroal: PID file </tmp//pgagroal.2345.pid> exists, is there another instance running ?

Issue with shutdown ?

@decarv
Copy link
Contributor Author

decarv commented Sep 15, 2024

pgagroal: PID file </tmp//pgagroal.2345.pid> exists, is there another instance running ?

Yes. I will investigate shutdown issues. However, from the CI output it could be anything, really.

@jesperpedersen
Copy link
Collaborator

Try and a TRACE log file for gcc and clang, and see if there are pointers there...

@jesperpedersen
Copy link
Collaborator

@decarv decarv force-pushed the new-linux-io-layer branch 2 times, most recently from e1b42f5 to ceb9ec3 Compare September 22, 2024 23:19
@decarv
Copy link
Contributor Author

decarv commented Sep 22, 2024

Please take a look at the latest commits. I decided to keep kqueue in this same PR for simplicity. I have just setup the testing environment for kqueue, so I haven't tested anything yet.

.github/ISSUE_TEMPLATE/bug_report.md Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
pgagroal.spec Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
src/include/ev.h Show resolved Hide resolved
src/include/ev.h Outdated
{
enum ev_type type; /**< Event type. */
int slot; /**< *CURRENTLY UNUSED* Slot number associated with the poll. */
#if HAVE_URING
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a union ?

src/include/ev.h Outdated Show resolved Hide resolved
@jesperpedersen
Copy link
Collaborator

Just a quick pass on the first part of the patch in order to give some comments that are probably general for the entire patch

@fluca1978
Copy link
Collaborator

I still have issues with ipv6 listening addresses: pgagroal is unresponsive if listen_address = *.
Changing listen_address to localhost allows me to test against pgbench, and so far it seems a little faster than the master branch, I'm still testing.
pgagroal-cli shutdown works fine, while stopping with SIGINT causes the pid file to stale.

@decarv
Copy link
Contributor Author

decarv commented Sep 24, 2024

I still have issues with ipv6 listening addresses: pgagroal is unresponsive if listen_address = *. Changing listen_address to localhost allows me to test against pgbench, and so far it seems a little faster than the master branch, I'm still testing.

I will investigate that further to understand what is happening. I don't see how ev.c is doing this (although it has to be it).

pgagroal-cli shutdown works fine, while stopping with SIGINT causes the pid file to stale.

Thank you. Fixed. Already on the next commit.

@decarv
Copy link
Contributor Author

decarv commented Jan 17, 2025

it is stalled. I cannot even SIGTERM the pgagroal, I've to kill it brutally.

It was inside an infinite loop waiting for all child processes to die. Maybe you can test that if you want.

Please test the patch.

I have added one or two #if DEBUG so just I can debug better. If you would like you could test the Release/Performance build.

@decarv
Copy link
Contributor Author

decarv commented Jan 17, 2025

CI failed because postgres crashed apparently. I will rebase and push again.

@decarv decarv force-pushed the new-linux-io-layer branch 3 times, most recently from f6fb9bb to d4de59b Compare January 17, 2025 23:20
@jesperpedersen
Copy link
Collaborator

@decarv What is up with epoll ?

Introduce ev.h and ev.c, establishing the
foundation for the new custom event loop,
`pgagroal_ev`.

Replace previous dependencies on libev with the
custom event loop.

For Linux, implement support for io_uring with a fallback to
epoll if io_uring is unavailable.

For BSD, implement support for kqueue.

Changelog
=========

2025-01-17:
- Fix regression added to the Debug build. `waitpid()`
inside `#if DEBUG` would block waiting for the running
child processes. Add WNOHANG to the function options so the
main process does not block.
- Remove '\n' from `pagroal_log_*()`
- Run uncrustify.sh
- Remove `printf()` debugging
- Modify CD/CI pipeline to improve function verify_running and
enable the CD/CI for kqueue, which was disabled.
- Change `pgagroal_log_error()` that informs errors in `kill()`
to `pgagroal_log_debug()`. I suppose these errors should happen
if pgagroal is not closely following up the death of its children.
Therefore, there is no need to flood the log with error messages.
Keep as debug because it is informative of something that could
be improved.

2025-01-16:
- Remove `pgagroal_ev_*_stop()` functions from main.c and vault.c
as these functions are not intended to be called from a child
process inheriting the ev loop. This does not make sense in
io_uring and for epoll and kqueue, just closing the fds is enough
as a precaution to prevent their use.
- Enhance debugging steps in `sigchld_handler()` to help debug
child processes termination.
- Add error handling to `kill()` to help debug child processes
termination.
- Allow return error on `pgagroal_ev_io_stop()` instead of exit
so the caller function can handle errors appropriately.
- Add a call to `setpgid()` when worker is created to ensure
child processes do not exit immediately if a SIGINT is issued
in the controlling terminal.
- Add a call to `pgagroal_ev_fork()` when a worker is created.

2025-01-13:
- Fix ASan report in `pgagroal_ev_io_stop()`
@decarv decarv force-pushed the new-linux-io-layer branch from d4de59b to 2e31f0b Compare January 18, 2025 00:03
@decarv
Copy link
Contributor Author

decarv commented Jan 18, 2025

@decarv What is up with epoll ?

New compile flags I think... I will address this in a new PR shortly.

@decarv
Copy link
Contributor Author

decarv commented Jan 18, 2025

As a side note, master could benefit from the CI script I'm currently running.

@decarv
Copy link
Contributor Author

decarv commented Jan 18, 2025

Yep. I believe it was runtime errors being returned to the shell.

TODO: store those logs instead of dumping in /dev/null.

@jesperpedersen
Copy link
Collaborator

      - name: Upload artifact for failed workflow
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: test logs
          path: |
            path/to/*.log

@jesperpedersen
Copy link
Collaborator

@decarv If you have patches that can be applied separately then create an issue and a pull request for it

@fluca1978
Copy link
Collaborator

fluca1978 commented Jan 20, 2025

Testing commit 2e31f0b on Rocky 9.5.
Production build, with uring.

First run seems fine:

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time /usr/pgsql-16/bin/pgbench -j 5 -c 20 -n -P 10 -T  60 -h localhost -p 5433 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && pgagroal-cli status details
 pid  | usename  | state  |                                            query                              
              
------+----------+--------+-------------------------------------------------------------------------------
--------------
 5484 | pgbench  | idle   | DISCARD ALL;
 5485 | pgbench  | idle   | DISCARD ALL;
 5486 | pgbench  | idle   | DISCARD ALL;
 5487 | pgbench  | idle   | DISCARD ALL;
 5488 | pgbench  | idle   | DISCARD ALL;
 5490 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curren
t_database();
(6 rows)

pgbench (16.6)
progress: 10.0 s, 1885.6 tps, lat 10.397 ms stddev 3.842, 0 failed
progress: 20.0 s, 1909.2 tps, lat 10.475 ms stddev 2.097, 0 failed
progress: 30.0 s, 1846.9 tps, lat 10.829 ms stddev 2.258, 0 failed
progress: 40.0 s, 1869.7 tps, lat 10.696 ms stddev 2.236, 0 failed
progress: 50.0 s, 1926.5 tps, lat 10.383 ms stddev 2.095, 0 failed
progress: 60.0 s, 1924.2 tps, lat 10.393 ms stddev 2.317, 0 failed
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 20
number of threads: 5
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 113639
number of failed transactions: 0 (0.000%)
latency average = 10.526 ms
latency stddev = 2.554 ms
initial connection time = 195.090 ms
tps = 1899.907562 (without initial connection time)
/usr/pgsql-16/bin/pgbench -j 5 -c 20 -n -P 10 -T 60 -h localhost -p 5433 -U    2.65s user 3.75s system 10% cpu 1:00.12 total
 pid  | usename  | state  |                                            query                              
              
------+----------+--------+-------------------------------------------------------------------------------
--------------
 5484 | pgbench  | idle   | END;
 5485 | pgbench  | idle   | END;
 5486 | pgbench  | idle   | END;
 5487 | pgbench  | idle   | END;
 5488 | pgbench  | idle   | END;
 5509 | pgbench  | idle   | END;
 5507 | pgbench  | idle   | END;
 5511 | pgbench  | idle   | END;
 5513 | pgbench  | idle   | END;
 5516 | pgbench  | idle   | END;
 5517 | pgbench  | idle   | END;
 5518 | pgbench  | idle   | END;
 5521 | pgbench  | idle   | END;
 5523 | pgbench  | idle   | END;
 5524 | pgbench  | idle   | END;
 5527 | pgbench  | idle   | END;
 5528 | pgbench  | idle   | END;
 5530 | pgbench  | idle   | END;
 5531 | pgbench  | idle   | END;
 5532 | pgbench  | idle   | DISCARD ALL;
 5540 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curren
t_database();
(21 rows)

2025-01-20 10:33:15 DEBUG configuration.c:4426 Configured event backend 'io_uring'
Header: 
  ClientVersion: 2.0.0
  Command: status-details
  Compression: none
  Encryption: none
  Output: text
  Timestamp: 20250120103315
Outcome: 
  Status: true
  Time: 00:00:00
Request: {}
Response: 
  ActiveConnections: 0
  Connections: 
    - AppName: ''
      Database: pgbench
      FD: 17
      PID: -1
      StartTime: 1737365525
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 18
      PID: -1
      StartTime: 1737365525
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 19
      PID: -1
      StartTime: 1737365525
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 20
      PID: -1
      StartTime: 1737365525
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 21
      PID: -1
      StartTime: 1737365525
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 34
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 27
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 32
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 24
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 26
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 37
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 16
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 31
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 28
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 25
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 29
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 23
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 36
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 30
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 22
      PID: -1
      StartTime: 1737365529
      Timestamp: 1737365589
      Username: pgbench
  Databases: 
    - Database: *
      Enabled: true
  Limits: 
    - ActiveConnections: 0
      Database: pgbench
      InitialConnections: 5
      MaxConnections: 20
      MinConnections: 5
      Username: pgbench
  MaxConnections: 20
  NumberOfServers: 1
  ServerVersion: 2.0.0
  Servers: 
    - Host: 127.0.0.1
      Port: 5432
      Server: rachel
      State: Primary
  Status: Running
  TotalConnections: 20

but the second run fails:

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time /usr/pgsql-16/bin/pgbench -j 5 -c 20 -n -P 10 -T  60 -h localhost -p 5433 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && pgagroal-cli status details
 pid  | usename  | state  |                                            query                              
              
------+----------+--------+-------------------------------------------------------------------------------
--------------
 5484 | pgbench  | idle   | DISCARD ALL;
 5485 | pgbench  | idle   | DISCARD ALL;
 5486 | pgbench  | idle   | DISCARD ALL;
 5487 | pgbench  | idle   | DISCARD ALL;
 5488 | pgbench  | idle   | DISCARD ALL;
 5509 | pgbench  | idle   | DISCARD ALL;
 5507 | pgbench  | idle   | DISCARD ALL;
 5511 | pgbench  | idle   | DISCARD ALL;
 5513 | pgbench  | idle   | DISCARD ALL;
 5516 | pgbench  | idle   | DISCARD ALL;
 5517 | pgbench  | idle   | DISCARD ALL;
 5518 | pgbench  | idle   | DISCARD ALL;
 5521 | pgbench  | idle   | DISCARD ALL;
 5523 | pgbench  | idle   | DISCARD ALL;
 5524 | pgbench  | idle   | DISCARD ALL;
 5527 | pgbench  | idle   | DISCARD ALL;
 5528 | pgbench  | idle   | DISCARD ALL;
 5530 | pgbench  | idle   | DISCARD ALL;
 5531 | pgbench  | idle   | DISCARD ALL;
 5532 | pgbench  | idle   | DISCARD ALL;
 5548 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curren
t_database();
(21 rows)

pgbench (16.6)
pgbench: error: connection to server at "localhost" (::1), port 5433 failed: received invalid error message
pgbench: error: could not create connection for client 7
/usr/pgsql-16/bin/pgbench -j 5 -c 20 -n -P 10 -T 60 -h localhost -p 5433 -U    0.01s user 0.01s system 0% cpu 29.714 total

and on the pgagroal side

2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 8 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 8 FD 24
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 7 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 7 FD 32
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 19 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 19 FD 22
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 2 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 2 FD 19
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 14 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 14 FD 25
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 13 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 13 FD 28
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 6 database pgbench user pgbench): Resource temporarily unavailable (socket 38 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 6 FD 27
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 17 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 17 FD 36
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 15 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 15 FD 29
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 9 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 9 FD 26
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 1 database pgbench user pgbench): Resource temporarily unavailable (socket 35 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 1 FD 18
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 4 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 4 FD 21
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 18 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 18 FD 30
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 12 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 12 FD 31
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 3 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 3 FD 20
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 11 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 11 FD 16
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 16 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 16 FD 23
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 10 database pgbench user pgbench): Resource temporarily unavailable (socket 33 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 10 FD 37
2025-01-20 10:33:53 DEBUG ev.c:961 ev: Connection closed
2025-01-20 10:33:53 ERROR message.c:1222 read_message_from_buffer: bad buffer
2025-01-20 10:33:53 WARN  pipeline_perf.c:183 [C] Client error (slot 5 database pgbench user pgbench): Resource temporarily unavailable (socket 39 status 2)
2025-01-20 10:33:53 INFO  message.c:1203 Message is NULL
2025-01-20 10:33:53 DEBUG pool.c:428 pgagroal_return_connection: Slot 5 FD 34
2025-01-20 10:33:53 DEBUG security.c:453 authenticate: BAD_PASSWORD
2025-01-20 10:33:53 DEBUG worker.c:291 client disconnect: 33
2025-01-20 10:33:53 DEBUG pool.c:1227 pgagroal_pool_status: 20/20

EDIT: Besides, testing the same commit on Rocky with epoll results in connections always increasing on the PostgreSQL side, at every run (it seems they are not properly released).
epoll is working fine according to me.

@decarv
Copy link
Contributor Author

decarv commented Jan 20, 2025

2025-01-20 10:33:53 DEBUG pool.c:1227 pgagroal_pool_status: 20/20

pgagroal cannot handle more connections than max connections, isn't this the reason?
You are using pgbench with -c 20 and connecting with psql.

@fluca1978
Copy link
Collaborator

2025-01-20 10:33:53 DEBUG pool.c:1227 pgagroal_pool_status: 20/20

pgagroal cannot handle more connections than max connections, isn't this the reason? You are using pgbench with -c 20 and connecting with psql.

Uhm, psql is used only once the pgbench has terminated, hence the only 20 connections to PostgreSQL are those opened by pgagroal. To ensure this, I connect psql directly without passing thru pgagroal.

@jesperpedersen
Copy link
Collaborator

jesperpedersen commented Jan 20, 2025

I think that setting -c X -j X to max_connections then we should not see FD: -1 in the status output.

pgbench is able to go to max_connections so the pool need to be able to do as well.

So, ./pgagroal-cli -c pgagroal.conf status details | grep "FD: -1" with any output should fail the build

Edit: I see this with both io_uring and epoll on F41

@jesperpedersen
Copy link
Collaborator

What does

 DEBUG ev.c:290 Child 56757 exited with status 0

mean ?

@decarv
Copy link
Contributor Author

decarv commented Jan 20, 2025

@fluca1978 I didn't pay attention to that. Sorry. Can you please try to reproduce again and show the steps? Maybe share the .conf and .databases? I cannot reproduce. That output happens when pgbench run is cancelled with Ctrl+C. That happens upstream also.

@jesperpedersen Do you mean have "FD: -1" mid run when maxing out the connections? I don't see it happening here. Can you share more information?

@decarv
Copy link
Contributor Author

decarv commented Jan 20, 2025

What does


 DEBUG ev.c:290 Child 56757 exited with status 0

mean ?

Just that one child exited with exit status 0. That message is printed by the main loop after receiving a SIGCHLD.

@jesperpedersen
Copy link
Collaborator

@jesperpedersen Do you mean have "FD: -1" mid run when maxing out the connections? I don't see it happening here. Can you share more information?

No, I mean after the run, so if the run is short enough it means that the connections havn't timed out, which means that only FD: x connections have been used. I used Luca's example, and did the grep after

@jesperpedersen
Copy link
Collaborator

jesperpedersen commented Jan 21, 2025

@decarv It could be a related issue since if you force it with -l and f.ex 8 0 0 you end up with FD: -1.

Anyway, test with -l and 8 8 0. And, then we need to test on the usage timestamp

@jesperpedersen
Copy link
Collaborator

@decarv

Just that one child exited with exit status 0. That message is printed by the main loop after receiving a SIGCHLD.

So, it is more like TRACE ? Or is it important to keep at this level ?

@decarv
Copy link
Contributor Author

decarv commented Jan 21, 2025

So, it is more like TRACE ? Or is it important to keep at this level ?

It s a trace. I will change it.

No, I mean after the run, so if the run is short enough it means that the connections havn't timed out, which means that only FD: x connections have been used. I used Luca's example, and did the grep after

Sorry. I still do not understand. Luca's connections have all been used. I will do a run with -l to see what am I missing.

cat <<EOF | grep FD | nl -w2 -s'. '
[Luca's output]
EOF
 1.       FD: 17
 2.       FD: 18
 3.       FD: 19
 4.       FD: 20
 5.       FD: 21
 6.       FD: 34
 7.       FD: 27
 8.       FD: 32
 9.       FD: 24
10.       FD: 26
11.       FD: 37
12.       FD: 16
13.       FD: 31
14.       FD: 28
15.       FD: 25
16.       FD: 29
17.       FD: 23
18.       FD: 36
19.       FD: 30
20.       FD: 22

@jesperpedersen
Copy link
Collaborator

@decarv I mean, when I do a similar run locally on my machine -- not Luca's actual run

@decarv
Copy link
Contributor Author

decarv commented Jan 21, 2025

So you mean debug build, max_connections = 8, and limit file for the db I'm testing: 8 8 0.

@jesperpedersen
Copy link
Collaborator

jesperpedersen commented Jan 21, 2025

Yes, but 8 8 0 will prefill the pool so there will be 8 valid FD:s -- try 8 0 0 and see how many FD: -1 you get.

We need 8 valid ones

@fluca1978
Copy link
Collaborator

Here it is a run, built in debug mode, with databases configured as 8 5 5:

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time /usr/pgsql-16/bin/pgbench -j 8 -c 8 -n -P 10 -T  60 -h localhost -p 5433 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && pgagroal-cli status details
  pid  | usename  | state  |                                            query                             
               
-------+----------+--------+------------------------------------------------------------------------------
---------------
 30086 | pgbench  | idle   | DISCARD ALL;
 30087 | pgbench  | idle   | DISCARD ALL;
 30088 | pgbench  | idle   | DISCARD ALL;
 30089 | pgbench  | idle   | DISCARD ALL;
 30090 | pgbench  | idle   | DISCARD ALL;
 30097 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curre
nt_database();
(6 rows)

pgbench (16.6)
progress: 10.0 s, 1617.1 tps, lat 4.881 ms stddev 8.375, 0 failed
progress: 20.0 s, 1981.8 tps, lat 4.036 ms stddev 0.713, 0 failed
progress: 30.0 s, 1980.9 tps, lat 4.038 ms stddev 0.987, 0 failed
progress: 40.0 s, 1961.7 tps, lat 4.078 ms stddev 0.933, 0 failed
progress: 50.0 s, 1967.4 tps, lat 4.066 ms stddev 0.556, 0 failed
progress: 60.0 s, 1424.7 tps, lat 5.568 ms stddev 8.717, 0 failed
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 8
number of threads: 8
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 109345
number of failed transactions: 0 (0.000%)
latency average = 4.396 ms
latency stddev = 5.245 ms
initial connection time = 136.138 ms
tps = 1819.280258 (without initial connection time)
/usr/pgsql-16/bin/pgbench -j 8 -c 8 -n -P 10 -T 60 -h localhost -p 5433 -U    2.37s user 3.32s system 9% cpu 1:02.05 total
  pid  | usename  | state  |                                            query                             
               
-------+----------+--------+------------------------------------------------------------------------------
---------------
 30086 | pgbench  | idle   | DISCARD ALL;
 30087 | pgbench  | idle   | DISCARD ALL;
 30088 | pgbench  | idle   | DISCARD ALL;
 30089 | pgbench  | idle   | DISCARD ALL;
 30090 | pgbench  | idle   | DISCARD ALL;
 30119 | pgbench  | idle   | DISCARD ALL;
 30120 | pgbench  | idle   | DISCARD ALL;
 30121 | pgbench  | idle   | DISCARD ALL;
 30127 |          | active | autovacuum: ANALYZE public.pgbench_history
 30139 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curre
nt_database();
(10 rows)

2025-01-22 08:44:54 DEBUG configuration.c:4426 Configured event backend 'io_uring'
Header: 
  ClientVersion: 2.0.0
  Command: status-details
  Compression: none
  Encryption: none
  Output: text
  Timestamp: 20250122084454
Outcome: 
  Status: true
  Time: 00:00:00
Request: {}
Response: 
  ActiveConnections: 0
  Connections: 
    - AppName: ''
      Database: pgbench
      FD: 17
      PID: -1
      StartTime: 1737531815
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 18
      PID: -1
      StartTime: 1737531816
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 19
      PID: -1
      StartTime: 1737531816
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 20
      PID: -1
      StartTime: 1737531816
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 21
      PID: -1
      StartTime: 1737531816
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 23
      PID: -1
      StartTime: 1737531833
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 22
      PID: -1
      StartTime: 1737531833
      Timestamp: 1737531893
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 16
      PID: -1
      StartTime: 1737531833
      Timestamp: 1737531893
      Username: pgbench
  Databases: 
    - Database: *
      Enabled: true
  Limits: 
    - ActiveConnections: 0
      Database: pgbench
      InitialConnections: 5
      MaxConnections: 8
      MinConnections: 5
      Username: pgbench
  MaxConnections: 8
  NumberOfServers: 1
  ServerVersion: 2.0.0
  Servers: 
    - Host: 127.0.0.1
      Port: 5432
      Server: rachel
      State: Primary
  Status: Running
  TotalConnections: 8

I don't see any FD: -1.

And here follows the test with pgbench -l:

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time /usr/pgsql-16/bin/pgbench -j 8 -c 8 -l -n -P 10 -T  60 -h localhost -p 5433 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && pgagroal-cli status details
  pid  | usename  | state  |                                            query                             
               
-------+----------+--------+------------------------------------------------------------------------------
---------------
 30271 | pgbench  | idle   | DISCARD ALL;
 30272 | pgbench  | idle   | DISCARD ALL;
 30273 | pgbench  | idle   | DISCARD ALL;
 30274 | pgbench  | idle   | DISCARD ALL;
 30275 | pgbench  | idle   | DISCARD ALL;
 30279 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curre
nt_database();
(6 rows)

pgbench (16.6)
progress: 10.0 s, 1943.0 tps, lat 4.066 ms stddev 1.689, 0 failed
progress: 20.0 s, 2003.7 tps, lat 3.990 ms stddev 0.555, 0 failed
progress: 30.0 s, 2012.9 tps, lat 3.972 ms stddev 0.534, 0 failed
progress: 40.0 s, 2016.4 tps, lat 3.965 ms stddev 0.601, 0 failed
progress: 50.0 s, 2020.5 tps, lat 3.957 ms stddev 0.537, 0 failed
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 8
number of threads: 8
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 120192
number of failed transactions: 0 (0.000%)
latency average = 3.983 ms
latency stddev = 0.849 ms
initial connection time = 126.805 ms
tps = 2007.206216 (without initial connection time)
/usr/pgsql-16/bin/pgbench -j 8 -c 8 -l -n -P 10 -T 60 -h localhost -p 5433 -U  2.68s user 3.67s system 10% cpu 1:01.05 total
  pid  | usename  | state  |                                            query                             
               
-------+----------+--------+------------------------------------------------------------------------------
---------------
 30271 | pgbench  | idle   | DISCARD ALL;
 30272 | pgbench  | idle   | DISCARD ALL;
 30273 | pgbench  | idle   | DISCARD ALL;
 30274 | pgbench  | idle   | DISCARD ALL;
 30275 | pgbench  | idle   | DISCARD ALL;
 30300 | pgbench  | idle   | DISCARD ALL;
 30301 | pgbench  | idle   | DISCARD ALL;
 30303 | pgbench  | idle   | DISCARD ALL;
 30319 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = curre
nt_database();
(9 rows)

2025-01-22 08:55:11 DEBUG configuration.c:4426 Configured event backend 'io_uring'
Header: 
  ClientVersion: 2.0.0
  Command: status-details
  Compression: none
  Encryption: none
  Output: text
  Timestamp: 20250122085511
Outcome: 
  Status: true
  Time: 00:00:00
Request: {}
Response: 
  ActiveConnections: 0
  Connections: 
    - AppName: ''
      Database: pgbench
      FD: 17
      PID: -1
      StartTime: 1737532436
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 18
      PID: -1
      StartTime: 1737532436
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 19
      PID: -1
      StartTime: 1737532436
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 20
      PID: -1
      StartTime: 1737532436
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 21
      PID: -1
      StartTime: 1737532436
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 16
      PID: -1
      StartTime: 1737532451
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 25
      PID: -1
      StartTime: 1737532451
      Timestamp: 1737532511
      Username: pgbench
    - AppName: ''
      Database: pgbench
      FD: 23
      PID: -1
      StartTime: 1737532451
      Timestamp: 1737532511
      Username: pgbench
  Databases: 
    - Database: *
      Enabled: true
  Limits: 
    - ActiveConnections: 0
      Database: pgbench
      InitialConnections: 5
      MaxConnections: 8
      MinConnections: 5
      Username: pgbench
  MaxConnections: 8
  NumberOfServers: 1
  ServerVersion: 2.0.0
  Servers: 
    - Host: 127.0.0.1
      Port: 5432
      Server: rachel
      State: Primary
  Status: Running
  TotalConnections: 8

after a fresh start of both PostgreSQL and pgagroal. I attach the pgbecnh logs.
pgbench_log.zip

@fluca1978
Copy link
Collaborator

I took some time to test commit 2e31f0b on FreeBSD, with the same configuration as above (pgagroal_databases.conf set to 20 5 5).

When using a parallelism of 10, it runs fine:

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time pgbench -c 10 -j 10 -n -P 10 -T  60 -h localhost -p 54322 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench
 pid  | usename  | state  |                                            query                                            
------+----------+--------+---------------------------------------------------------------------------------------------
 1537 | pgbench  | idle   | DISCARD ALL;
 1539 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = current_database();
 1533 | pgbench  | idle   | DISCARD ALL;
 1534 | pgbench  | idle   | DISCARD ALL;
 1535 | pgbench  | idle   | DISCARD ALL;
 1536 | pgbench  | idle   | DISCARD ALL;
(6 rows)

pgbench (17.0)
progress: 10.0 s, 739.0 tps, lat 12.673 ms stddev 21.812, 0 failed
progress: 20.0 s, 674.1 tps, lat 14.837 ms stddev 16.419, 0 failed
progress: 30.0 s, 679.8 tps, lat 14.759 ms stddev 17.377, 0 failed
progress: 40.0 s, 656.4 tps, lat 15.180 ms stddev 21.334, 0 failed
progress: 50.0 s, 692.5 tps, lat 14.425 ms stddev 21.338, 0 failed
progress: 60.0 s, 736.0 tps, lat 13.652 ms stddev 20.415, 0 failed
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1000
query mode: simple
number of clients: 10
number of threads: 10
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 41788
number of failed transactions: 0 (0.000%)
latency average = 14.632 ms
latency stddev = 35.667 ms
initial connection time = 594.640 ms
tps = 677.781144 (without initial connection time)
pgbench -c 10 -j 10 -n -P 10 -T 60 -h localhost -p 54322 -U pgbench pgbench  1.80s user 1.23s system 4% cpu 1:02.30 total
 pid  | usename  | state  |                                            query                                            
------+----------+--------+---------------------------------------------------------------------------------------------
 1553 | pgbench  | idle   | END;
 1560 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = current_database();
 1537 | pgbench  | idle   | DISCARD ALL;
 1556 | pgbench  | idle   | DISCARD ALL;
 1555 | pgbench  | idle   | END;
 1557 | pgbench  | idle   | END;
 1554 | pgbench  | idle   | END;
 1533 | pgbench  | idle   | END;
 1534 | pgbench  | idle   | END;
 1535 | pgbench  | idle   | END;
 1536 | pgbench  | idle   | DISCARD ALL;
(11 rows)

but note the END status. An "immediate" re-run of the same test shows that connections are all in DISCARD ALL status and runs fine again (I tested multiple times):

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time pgbench -c 10 -j 10 -n -P 10 -T  60 -h localhost -p 54322 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench
 pid  | usename  | state  |                                            query                                            
------+----------+--------+---------------------------------------------------------------------------------------------
 1580 | pgbench  | idle   | DISCARD ALL;
 1581 | pgbench  | idle   | DISCARD ALL;
 1582 | pgbench  | idle   | DISCARD ALL;
 1612 | pgbench  | idle   | DISCARD ALL;
 1583 | pgbench  | idle   | DISCARD ALL;
 1644 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = current_database();
 1584 | pgbench  | idle   | DISCARD ALL;
 1608 | pgbench  | idle   | DISCARD ALL;
 1609 | pgbench  | idle   | DISCARD ALL;
 1610 | pgbench  | idle   | DISCARD ALL;
 1611 | pgbench  | idle   | DISCARD ALL;
(11 rows)

pgbench (17.0)
progress: 10.0 s, 733.1 tps, lat 13.509 ms stddev 19.557, 0 failed
progress: 20.0 s, 711.4 tps, lat 14.063 ms stddev 20.720, 0 failed
progress: 30.0 s, 715.7 tps, lat 13.959 ms stddev 14.032, 0 failed
progress: 40.0 s, 707.0 tps, lat 14.121 ms stddev 16.787, 0 failed
progress: 50.0 s, 712.1 tps, lat 14.028 ms stddev 21.980, 0 failed
progress: 60.0 s, 704.8 tps, lat 14.239 ms stddev 17.753, 0 failed
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1000
query mode: simple
number of clients: 10
number of threads: 10
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 42851
number of failed transactions: 0 (0.000%)
latency average = 14.570 ms
latency stddev = 49.395 ms
initial connection time = 87.918 ms
tps = 661.295437 (without initial connection time)
pgbench -c 10 -j 10 -n -P 10 -T 60 -h localhost -p 54322 -U pgbench pgbench  1.68s user 1.31s system 4% cpu 1:04.92 total
 pid  | usename  | state  |                                            query                                            
------+----------+--------+---------------------------------------------------------------------------------------------
 1580 | pgbench  | idle   | DISCARD ALL;
 1581 | pgbench  | idle   | DISCARD ALL;
 1582 | pgbench  | idle   | DISCARD ALL;
 1612 | pgbench  | idle   | DISCARD ALL;
 1583 | pgbench  | idle   | END;
 1667 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = current_database();
 1584 | pgbench  | idle   | END;
 1608 | pgbench  | idle   | DISCARD ALL;
 1609 | pgbench  | idle   | DISCARD ALL;
 1610 | pgbench  | idle   | DISCARD ALL;
 1611 | pgbench  | idle   | DISCARD ALL;
(11 rows)

However, if I increase -c and -j even by a unit, pgagroal does not work at all, and nothing appears in the logs (even if I restart pgagroal from scratch):

% psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench && time pgbench -c 11 -j 11 -n -P 10 -T  60 -h localhost -p 54322 -U pgbench pgbench && psql -U postgres -c "select pid, usename, state, query from pg_stat_activity where datname = current_database();" pgbench
 pid  | usename  | state  |                                            query                                            
------+----------+--------+---------------------------------------------------------------------------------------------
 1676 | pgbench  | idle   | DISCARD ALL;
 1682 | postgres | active | select pid, usename, state, query from pg_stat_activity where datname = current_database();
 1680 | pgbench  | idle   | DISCARD ALL;
 1679 | pgbench  | idle   | DISCARD ALL;
 1678 | pgbench  | idle   | DISCARD ALL;
 1677 | pgbench  | idle   | DISCARD ALL;
(6 rows)

pgbench (17.0)
^C
pgbench -c 11 -j 11 -n -P 10 -T 60 -h localhost -p 54322 -U pgbench pgbench  0.00s user 0.01s system 0% cpu 3:31.88 total

@decarv
Copy link
Contributor Author

decarv commented Jan 27, 2025

Thanks a lot @fluca1978.
I will have a look at it this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants