-
Notifications
You must be signed in to change notification settings - Fork 215
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
[Merged by Bors] - sql: add Database.WithConnection #6445
Conversation
This adds a possibility to take a connection from the pool to use it via the Executor interface, and return it later when it's no longer needed. This avoids connection pool overhead in cases when a lot of quries need to be made, but the use of read transactions is not needed. Using read transactions instead of simple connections has the side effect of blocking WAL checkpoints.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6445 +/- ##
=========================================
- Coverage 79.9% 79.9% -0.1%
=========================================
Files 352 352
Lines 46096 46126 +30
=========================================
+ Hits 36865 36870 +5
- Misses 7142 7161 +19
- Partials 2089 2095 +6 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
bors merge |
------- ## Motivation In some situations (most notably, syncv2) a lot of database queries need to be made with no need for a read or write transaction. Database connection pool adds noticeable delays to the queries. Using read transactions instead of simple connections has the side effect of blocking WAL checkpoints.
Build failed: |
systest failure:
This looks like stuck network or smth like that. |
I'm not exactly sure what went wrong, but all smeshers were deployed quite late: https://grafana.spacemesh.dev/goto/wJ_klsGHg?orgId=1
|
bors merge |
## Motivation In some situations (most notably, syncv2) a lot of database queries need to be made with no need for a read or write transaction. Database connection pool adds noticeable delays to the queries. Using read transactions instead of simple connections has the side effect of blocking WAL checkpoints.
Build failed:
|
bors merge |
## Motivation In some situations (most notably, syncv2) a lot of database queries need to be made with no need for a read or write transaction. Database connection pool adds noticeable delays to the queries. Using read transactions instead of simple connections has the side effect of blocking WAL checkpoints.
Pull request successfully merged into develop. Build succeeded:
|
Motivation
In some situations (most notably, syncv2) a lot of database queries
need to be made with no need for a read or write transaction.
Database connection pool adds noticeable delays to the queries.
Using read transactions instead of simple connections has the side
effect of blocking WAL checkpoints.
Description
This adds a possibility to take a connection from the pool to use it
via the Executor interface, and return it later when it's no longer
needed. This avoids connection pool overhead in cases when a lot of
quries need to be made, but the use of read transactions is not
needed.
Additionally, this PR removes unused
Rollback
method from migrations.The failed migrations are reverted either by rolling back the transactions
or dropping the temporary database used when vacuuming is needed.
UPD:
Rollback
method can be useful after all, so reverted this part of the PR.