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(logging): Log slow acquires from connection pool #3073

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

iamjpotts
Copy link
Contributor

If the connection pool is full, and all connections are in use, the next request for a connection involving PoolInner::acquire will block until a connection is released back to the pool.

  • Track the time taken to acquire a connection from the connection pool
  • Warn if a time threshold is exceeded
  • Threshold duration is configurable via PoolOptions
  • Threshold defaults to three seconds, which should be reasonable to prevent false positives for apps connecting to a database server that is nearby on the network

The default tries to avoid reporting a slow acquire when the pool grows itself within its capacity limit by creating a new connection.

@abonander
Copy link
Collaborator

@iamjpotts are you planning on completing this draft PR?

@iamjpotts
Copy link
Contributor Author

@iamjpotts are you planning on completing this draft PR?

Yes. I wanted to beat it up a bit more first.

@iamjpotts iamjpotts marked this pull request as ready for review March 6, 2024 04:31
sqlx-core/src/pool/options.rs Outdated Show resolved Hide resolved
@iamjpotts iamjpotts force-pushed the 20240222-log-slow-acquires branch 2 times, most recently from cb6ceea to e3dd0b8 Compare March 7, 2024 04:16
sqlx-core/src/pool/options.rs Outdated Show resolved Hide resolved
sqlx-core/src/pool/inner.rs Outdated Show resolved Hide resolved
sqlx-core/src/pool/options.rs Show resolved Hide resolved
sqlx-core/src/pool/inner.rs Outdated Show resolved Hide resolved
@iamjpotts iamjpotts force-pushed the 20240222-log-slow-acquires branch 4 times, most recently from 217cec7 to 49f3f45 Compare March 15, 2024 16:12
@abonander abonander merged commit d600ec0 into launchbadge:main Apr 2, 2024
62 checks passed
jqphu pushed a commit to jqphu/sqlx that referenced this pull request Apr 19, 2024
@iamjpotts iamjpotts deleted the 20240222-log-slow-acquires branch August 21, 2024 01:37
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