[PR #1583] [MERGED] feat: add pqsql configs for open and idle connections #2191

Closed
opened 2025-12-29 03:20:09 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1583
Author: @pallabpain
Created: 10/30/2023
Status: Merged
Merged: 2/9/2024
Merged by: @kradalby

Base: mainHead: fix/postgres-connections


📝 Commits (1)

  • c052d6c add pgsql configs for open and idle connections

📊 Changes

4 files changed (+278 additions, -233 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 config-example.yaml (+3 -0)
📝 hscontrol/db/db.go (+243 -217)
📝 hscontrol/types/config.go (+31 -16)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/1583 **Author:** [@pallabpain](https://github.com/pallabpain) **Created:** 10/30/2023 **Status:** ✅ Merged **Merged:** 2/9/2024 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `fix/postgres-connections` --- ### 📝 Commits (1) - [`c052d6c`](https://github.com/juanfont/headscale/commit/c052d6cbe7bb08340cf876bd99e0be5c90f18375) add pgsql configs for open and idle connections ### 📊 Changes **4 files changed** (+278 additions, -233 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `config-example.yaml` (+3 -0) 📝 `hscontrol/db/db.go` (+243 -217) 📝 `hscontrol/types/config.go` (+31 -16) </details> ### 📄 Description ### 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. <!-- Headscale is "Open Source, acknowledged contribution", this means that any contribution will have to be discussed with the Maintainers before being submitted. This model has been chosen to reduce the risk of burnout by limiting the maintenance overhead of reviewing and validating third-party code. Headscale is open to code contributions for bug fixes without discussion. If you find mistakes in the documentation, please submit a fix to the documentation. --> <!-- Please tick if the following things apply. You… --> - [x] read the [CONTRIBUTING guidelines](README.md#contributing) - [x] raised a GitHub issue or discussed it on the projects chat beforehand - [ ] added unit tests - [ ] added integration tests - [x] updated documentation if needed - [x] updated CHANGELOG.md <!-- If applicable, please reference the issue using `Fixes #XXX` and add tests to cover your new code. --> ### Depends * https://github.com/juanfont/headscale/pull/1700 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:20:09 +01:00
adam closed this issue 2025-12-29 03:20:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2191