Skip to content

Allow configuring maximum idle connections#608

Open
jBouyoud wants to merge 1 commit into
cyrilgdn:mainfrom
Swile:idle-conn
Open

Allow configuring maximum idle connections#608
jBouyoud wants to merge 1 commit into
cyrilgdn:mainfrom
Swile:idle-conn

Conversation

@jBouyoud

@jBouyoud jBouyoud commented Jan 7, 2026

Copy link
Copy Markdown

This PR adds support for configuring the maximum number of idle connections in the PostgreSQL connection pool.

Changes

  • Added MaxIDleConns field to the Config struct
  • Configured SetMaxIdleConns on the database connection using the new parameter
  • Allows better control over connection pool behavior and resource management

Context

This enhancement provides more flexibility in managing database connections, particularly useful for optimizing performance in huge ressources contexts

@cyrilgdn

Copy link
Copy Markdown
Owner

@jBouyoud Could you rebase your PR on main please (I can't do it with the UI, you probably didn't allow update by maintainer) so I can trigger the tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new provider configuration option to control the PostgreSQL connection pool’s maximum idle connections, wiring it from Terraform schema into the internal client configuration and documenting the new argument.

Changes:

  • Added a max_idle_connections provider argument and plumbed it into the provider configuration.
  • Extended the internal Config to carry the idle-connection limit and applied it via db.SetMaxIdleConns(...).
  • Updated website documentation to describe the new setting.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
website/docs/index.html.markdown Documents the new max_idle_connections provider argument and its default/semantics.
postgresql/provider.go Adds the new schema field and passes it into the provider Config during configuration.
postgresql/config.go Adds the new Config field and applies it to the *sql.DB pool via SetMaxIdleConns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/docs/index.html.markdown Outdated
Comment on lines +175 to +176
* `max_idle_connections` - (Optional) Maximum number of idle connections.
Zero means no idle connections, useful when Db is managed in the same terraform state. The default is `0`.
Comment thread postgresql/provider.go Outdated
Comment on lines +199 to +200
Description: "Maximum number of idle connections. Zero means no idle connections, useful when Db is managed in the same terraform state.",
ValidateFunc: validation.IntAtLeast(-1),
Comment thread postgresql/config.go
Comment on lines 181 to 183
MaxConns int
MaxIDleConns int
ExpectedVersion semver.Version
Comment thread postgresql/config.go Outdated
Comment on lines 309 to 310
db.SetMaxIdleConns(c.config.MaxIDleConns)
db.SetMaxOpenConns(c.config.MaxConns)
Comment thread postgresql/provider.go
Comment on lines 391 to 394
ConnectTimeoutSec: d.Get("connect_timeout").(int),
MaxConns: d.Get("max_connections").(int),
MaxIDleConns: d.Get("max_idle_connections").(int),
ExpectedVersion: version,
Comment thread postgresql/provider.go
Comment on lines 391 to 394
ConnectTimeoutSec: d.Get("connect_timeout").(int),
MaxConns: d.Get("max_connections").(int),
MaxIDleConns: d.Get("max_idle_connections").(int),
ExpectedVersion: version,
@jBouyoud

Copy link
Copy Markdown
Author

Hi @cyrilgdn 👋 I've rebased this PR onto the latest main (v1.27.0) — conflict-free and mergeable. I also addressed the Copilot review comments: fixed the MaxIdleConns typo, clarified the schema description/docs, and added a unit test for the mapping. Local go build/go vet/unit tests pass; the CI workflows are waiting for your approval to run. Could you take a look when you have a moment? Thanks a lot for maintaining this provider!

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.

3 participants