-
Notifications
You must be signed in to change notification settings - Fork 664
Refactor DbProgram to borrow transaction #9
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
Conversation
It needs to borrow transaction from outside so that it could run its own operations but leave commit/rollback to the owner, otherwise it's easy to introduce deadlocks. While at it, also changed RelationalDb to be borrowed as well to avoid unnecessary clones as some callsites already have &DbProgram, while others have Arc<DbProgram>.
|
|
mamcx
left a comment
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.
LGTM
|
|
||
| pub fn execute_sql(db: &RelationalDB, ast: Vec<CrudExpr>) -> Result<Vec<MemTable>, DBError> { | ||
| let total = ast.len(); | ||
| db.with_auto_commit(|tx| { |
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.
A general comment: Was not the idea to not have locks in the inner functions but something is acquired higher in the stack? Anyway, I don't see anything that could look bad..
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.
@mamcx What is the different between this function and execute_single_sql. Is this one not suppose to be a transaction? Either way I think this fixes the issue we have for now.
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.
Was not the idea to not have locks in the inner functions but something is acquired higher in the stack?
I tried not to change SQL behaviour too much for now, only propagate tx from higher up in reducers.
cloutiertyler
left a comment
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.
LGTM
|
|
||
| pub fn execute_sql(db: &RelationalDB, ast: Vec<CrudExpr>) -> Result<Vec<MemTable>, DBError> { | ||
| let total = ast.len(); | ||
| db.with_auto_commit(|tx| { |
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.
@mamcx What is the different between this function and execute_single_sql. Is this one not suppose to be a transaction? Either way I think this fixes the issue we have for now.
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
We support primaryKey fields now, thus we can also perform an update operation on the client by utilizing the primaryKey
* upgrade to 1.0.0-rc1 * fixed compilation errors --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com> Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Update after the change in #309.
* First pass * Committing meta file * Removed option type - unneeded * Implementing new some converter * Some converter updates * Tons of fixes here * Cleaned up the some/enum serialization implementation --------- Co-authored-by: John Detter <no-reply@boppygames.gg>
We support primaryKey fields now, thus we can also perform an update operation on the client by utilizing the primaryKey
* First pass * Committing meta file * Removed option type - unneeded * Implementing new some converter * Some converter updates * Tons of fixes here * Cleaned up the some/enum serialization implementation --------- Co-authored-by: John Detter <no-reply@boppygames.gg>
It needs to borrow transaction from outside so that it could run its own operations but leave commit/rollback to the owner, otherwise it's easy to introduce deadlocks.
While at it, also changed RelationalDb to be borrowed as well to avoid unnecessary clones as some callsites already have &DbProgram, while others have Arc.
Description of Changes
API
If the API is breaking, please state below what will break