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

✨ feat: add pqsql configs for open and idle connections #1583

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

pallabpain
Copy link
Contributor

@pallabpain pallabpain commented Oct 30, 2023

Description

When Postgres is used as the backing database for headscale, it does not set a limit on maximum open and idle connections which leads to hundreds of open connections to the Postgres server. This commit fixes that by setting up a connection pool while creating the gorm DB instance.

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

Depends

@pallabpain pallabpain marked this pull request as ready for review January 11, 2024 13:02
hscontrol/db/db.go Outdated Show resolved Hide resolved
@pallabpain pallabpain force-pushed the fix/postgres-connections branch 3 times, most recently from 447eb2f to 551c460 Compare January 17, 2024 10:09
config-example.yaml Outdated Show resolved Hide resolved
@pallabpain pallabpain changed the title fix(db): sets max open and idle connections for postgres 🐛 fix(db): sets max open and idle connections for postgres Jan 28, 2024
@kradalby
Copy link
Collaborator

kradalby commented Feb 9, 2024

Sorry for the delay, this should be up and running

@pallabpain
Copy link
Contributor Author

Sorry for the delay, this should be up and running

@kradalby Thank you. I've updated the PR.

I may have also run make fmt that has resulted in a larger diff in the PR. 😅

@pallabpain pallabpain changed the title 🐛 fix(db): sets max open and idle connections for postgres add pqsql configs for open and idle connections Feb 9, 2024
@pallabpain pallabpain changed the title add pqsql configs for open and idle connections ✨ feat: add pqsql configs for open and idle connections Feb 9, 2024
When Postgres is used as the backing database for headscale,
it does not set a limit on maximum open and idle connections
which leads to hundreds of open connections to the Postgres
server.

This commit introduces the configuration variables to set those
values and also sets default while opening a new postgres connection.
@kradalby kradalby merged commit 9047c09 into juanfont:main Feb 9, 2024
51 checks passed
@SuperSandro2000
Copy link
Contributor

@pallabpain does that mean headscale is now usable with postgres?

@pallabpain
Copy link
Contributor Author

@pallabpain does that mean headscale is now usable with postgres?

@SuperSandro2000 It was already usable with Postgres. It now makes use of connection pooling as well.

@SuperSandro2000
Copy link
Contributor

I constantly ran into #1584 which rendered headscale completely broken for me. It's that issue now fixed and can be closed?

@pallabpain
Copy link
Contributor Author

pallabpain commented Feb 12, 2024

Yes, that should be resolved with this fix. In order to mitigate the issue with a previous stable version of headscale, you can consider running PGBouncer.

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

Successfully merging this pull request may close these issues.

None yet

3 participants