-
Notifications
You must be signed in to change notification settings - Fork 219
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: wallet optimize output manager db operations #4663
feat: wallet optimize output manager db operations #4663
Conversation
9abc858
to
c53a61f
Compare
Optimized output manager database operations to do as much work as possible inside the SQL database instead of inside Rust code.
c53a61f
to
903351c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, maybe add a transaction in a new PR
&conn, | ||
)?; | ||
} | ||
update_outputs_with_tx_id_and_status_to_new_status( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_outputs_with_tx_id_and_status_to_new_status( | |
// use a transaction here | |
conn.transaction(|| { | |
update_outputs_with_tx_id_and_status_to_new_status( |
&conn, | ||
)?; | ||
} | ||
diesel::update(outputs::table.filter(outputs::status.eq(OutputStatus::ShortTermEncumberedToBeReceived as i32))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add a transaction over these two statements
Description --- Added SQL transactions to the encumbering queries to make the entire operation atomic. _(This is a further safeguard as a follow-on to #4663.)_ Motivation and Context --- It is possible that an independent thread can change the same SQL data (outputs) that were selected and verified to be encumbered just before it is encumbered. Fixes #4701. How Has This Been Tested? --- Passed unit tests Passed cucumber tests
Description
Optimized output manager and contacts liveness database operations to do as much work as possible inside the SQL database instead of inside Rust code. These changes are most noticeable where a query would return a number of outputs and followed by updating each output one by one.
Motivation and Context
See #4621
How Has This Been Tested?