-
-
Notifications
You must be signed in to change notification settings - Fork 12
Drop impl for Transaction has silent side effects #61
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
Comments
The transaction calls To panic in the drop code is a valid alternative, but i don't like the idea to do this, as it would complicate quite a lot the error handling (basically impossible to use the |
I don't like this idea, as it is really easy to not destroy the transaction this way
This one seems ok to me
I though of creating a "default transaction" that is managed by the connection and is reused for the lifetime of it, but did not find a good way to implement this yet
I did not really understand this one, why would |
In number #58 we eliminated all but one path toward executing the
Drop::drop
impl ofTransaction
While working on that PR i was thinking about whether there really should be side effects in a
Drop
impl at all (for example rolling back)Was a conscious decision made when
Drop
was implemented at first?I actually don't know what the idiomatic way is in Rust here, but it seems like it could be a silent source of bugs or unintended behavior, for example if the transaction handle was already invalidated by some other means (maybe even not implemented yet- every new
mut self
method will have to be on guard for such behavior)Alternative ideas-
set_drop_behavior
like rusqlite, but where the user is forced to make an initial choice inTransaction::new()
? that way they can't manually construct a Transaction without being made aware of the behavior.TransactionData
should actually be managed byConnection
and notTransaction
? I wonder if there could be a trick here using lifetimes (say ifI think it would be the other way around. IfTransactionData
is borrowed byTransaction
TransactionData<'a>
held a&mut 'a Transaction
then it would mean we had to dropTransactionData
before theTransaction
)Transaction
as it is, isn't the right abstraction to leverage Rust safety. Maybe it should really beTransactionBuilder<InconsistentState>
(needs commit/rollback) andTransactionBuilder<ConsistentState>
(no pending writes) and you can only pass theConsistentState
one to aConnection
to execute. These could potentially be implemented asFuture
s` (but we just run them in a single thread because of Firebird limitations). I'm not sure if that would mean having to use a bunch of complicated async/await machinery or not.relates to #56
Thoughts?
The text was updated successfully, but these errors were encountered: