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](https://private-user-images.githubusercontent.com/77307340/282863697-feeb4ebe-a37d-438e-893a-0d6d7cacf8e8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE2NTA0ODksIm5iZiI6MTcyMTY1MDE4OSwicGF0aCI6Ii83NzMwNzM0MC8yODI4NjM2OTctZmVlYjRlYmUtYTM3ZC00MzhlLTg5M2EtMGQ2ZDdjYWNmOGU4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIyVDEyMDk0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ4YTNiNDE2OTIxNDg4YjMwODVkYzllNWY0MjBhMGFhM2YwZWM3M2IyZmQ0YTI4NDliNzE2MjgyN2I3OGFhOGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hrfW6DMBfB9aEQU8UPxQ5QVoJrs6BgM4Dc1uFe1Wn84)
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- 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](https://private-user-images.githubusercontent.com/77307340/282865532-f048dd04-a555-4aae-9e23-bbe69996b694.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE2NTA0ODksIm5iZiI6MTcyMTY1MDE4OSwicGF0aCI6Ii83NzMwNzM0MC8yODI4NjU1MzItZjA0OGRkMDQtYTU1NS00YWFlLTllMjMtYmJlNjk5OTZiNjk0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIyVDEyMDk0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNmODZmNTQ1ZTcyNjRjOGNkZTU5Y2U0ZGY4MTljMDI0N2UwMDJjMDY4YzhiZmZiYzNiZTk5NThiZWQwOTg1YWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.q4qEllZZc6039sHHiZ5_t6Zal96u4_jC_bQUWOy0WeM)
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.