Skip to content

Use native Golang connection pooling to reduce number of connections opened for postgres (#195) #239

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ajcaldera1
Copy link

Description of your changes

This change reduces the number of connections that must be opened to support a reconciliation job. On execution of New() it opens a connection pool with a maximum of 5 connections (hard-coded in this iteration) with a max lifetime of 10 minutes. After 2 minutes, any idle (unused) connections will be terminated to a minimum of 2 connections. These connections are then reused across the entire lifecycle.

Fixes #195

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

e2e tests done and tested by production observations over the last 7 months.

dependabot bot and others added 10 commits May 28, 2025 15:30
…trib#232)

Bumps google.golang.org/protobuf from 1.31.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Alan Caldera <[email protected]>
* fix: enable management policies

Signed-off-by: Jesús Fernández <[email protected]>

* fix: linter

Signed-off-by: Jesús Fernández <[email protected]>

* chore: offload lint changes to crossplane-contrib#216

Signed-off-by: Jesús Fernández <[email protected]>

* chore: revert changes as per peer review

Signed-off-by: Jesús Fernández <[email protected]>

---------

Signed-off-by: Jesús Fernández <[email protected]>
Signed-off-by: Alan Caldera <[email protected]>
…#236)

* chore: remove duplicate entry of golangci version

Signed-off-by: Jesús Fernández <[email protected]>

* chore: bump up versions for crossplane 1.20

Signed-off-by: Jesús Fernández <[email protected]>

* chore: restore changes

Signed-off-by: Jesús Fernández <[email protected]>

---------

Signed-off-by: Jesús Fernández <[email protected]>
Signed-off-by: Alan Caldera <[email protected]>
…e before mutating it. This will help cut down the number of ALTER ROLE statements that would otherwise needlessly fire for each role.

Signed-off-by: Alan Caldera <[email protected]>
Signed-off-by: Alan Caldera <[email protected]>
Signed-off-by: Alan Caldera <[email protected]>
@chlunde
Copy link
Collaborator

chlunde commented May 30, 2025

I think you could drop all commits in this branch and run

git cherry-pick 24a83a01cfcf758c580bf7930301d256d4d32781
git fetch upstream # or origin
git rebase -i upstream/master  # or origin/master
# and then remove all commits except the last one

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.

Provider should use connection pooling or single transaction to minimize load on database when reconciling
3 participants