-
Notifications
You must be signed in to change notification settings - Fork 214
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] - Improve performance of proposal builder by not DB inserting active set if not necessary #6422
Conversation
…t an immediate transaction
… put back into the pool
bors try |
bors try |
tryAlready running a review |
tryBuild failed: |
bors merge |
…t if not necessary (#6422) ## Motivation Closes #6418 The first proposal created by a node for any identity triggers persisting the activeset that is used by all identities of the node. This can be a slow process (especially when many ATXs are received by the node) and is usually not necessary, because the activeset is most likely already in the DB. This PR moves persisting the active set to the beginning of an epoch and avoids a DB write if not necessary (which will usually be the case).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6422 +/- ##
=======================================
Coverage 79.7% 79.7%
=======================================
Files 328 328
Lines 42977 42984 +7
=======================================
+ Hits 34256 34292 +36
+ Misses 6782 6753 -29
Partials 1939 1939 ☔ View full report in Codecov by Sentry. |
Pull request successfully merged into develop. Build succeeded:
|
## Motivation Follow up to #6422: Update changlog and remove unused metric.
## Motivation Follow up to #6422: Update changlog and remove unused metric.
Motivation
Closes #6418
The first proposal created by a node for any identity triggers persisting the activeset that is used by all identities of the node. This can be a slow process (especially when many ATXs are received by the node) and is usually not necessary, because the activeset is most likely already in the DB.
This PR moves persisting the active set to the beginning of an epoch and avoids a DB write if not necessary (which will usually be the case).
Description
All uses of
WithTx
have been renamed toWithTxImmediate
(because they are). A newWithTx
was added that starts a normal instead of an immediate transaction.This transaction is used to first do a select on the available active sets in the DB and only write the used active set if it doesn't exist yet. Since most nodes use the same active set that is pre-shared this will almost never trigger an actual insert preventing the requirement to acquire a DB write lock and speed up the process.
Additionally I fixed an issue where if beginning a transaction failed (because for instance the TX was canceled already via context), the connection used was not returned to the DB pool. This fixes the flaky
TestSyncer
test in themalsync
package and ensures this doesn't happen during normal node operation.Test Plan
existing tests pass
TODO