postgresml/pgcat

PgCat holds more idle connections than PgBouncer

Opened this issue · 1 comments

Describe the bug
A clear and concise description of what the bug is.

We've migrated several databases to PgCat from PgBouncer and found that with the same connection limits and timeouts configured PgCat ends up creating more connections

image

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Idle connections aren't great to have on the DB and it would be good to figure out why PgCat doesn't evict connections and/or requires more connections

Screenshots
If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

I think this is because bb8 asynchronously spawns new connections when multiple clients request one and the pool doesn't have any idle ones available: https://github.com/djc/bb8/blob/main/bb8/src/inner.rs#L102-L147. I believe Pgb is doing the same thing synchronously, but I don't recall.