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

Improve max_lifetime handling #3065

Merged
merged 4 commits into from
Mar 5, 2024
Merged

Conversation

mirek26
Copy link
Contributor

@mirek26 mirek26 commented Feb 18, 2024

Does your PR solve an issue?

Implements proposal (1) + (2) from #3051

  1. Move max lifetime checking from acquire to release. This reduces the number of query-time reconnections due to max lifetime
  2. Improves the maintenance task to handle connection replacement if min_connections > 0. This especially improves the scenario where the application is alive for a significant amount of time before it starts getting traffic. Without this change, sqlx opens min_connections connections and they just sit idle. Then query time, we discover they are over max_lifetime and have to reconnect. With this change, the connections are actually replaced every max_lifetime and can be used when needed.

I'm open to other ideas but this seems to me like a strictly better default than the current one. One question is whether we should be replacing connection below min_connections due to being idle - this PR does that but I can see the argument for doing that only with max_lifetime

@abonander abonander merged commit b4f6596 into launchbadge:main Mar 5, 2024
64 checks passed
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.

2 participants