You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If ActiveRecord::Base.transaction is called while already inside a transaction it does not create a "nested" transaction (actually a savepoint) c.f. Nested Transactions in the Rails documentation
This means the following code will lead to an incorrect state in the DB:
MyModel.transactiondobegindomy_model.transition_to(:something_that_fails)rescueError# handle it somehow, expecting the transition to have been rolled back# but because we were already in a tx nothing happened, the db has been modified# and all guarantees are now voidendend
I actually ran into the opposite issue with aasm a while back, so the ideal solution would be to make the requires_new setting on the AR transaction configurable, c.f. aasm/aasm#107
The text was updated successfully, but these errors were encountered:
@MSch are you able to provide steps to reproduce or (even better) a failing test case for this? What you've described makes sense in the abstract (you could get into a state where you think a transition has rolled back but it hasn't) but I'm struggling to make that happen in reality.
https://github.com/gocardless/statesman/blob/master/lib/statesman/adapters/active_record.rb#L73
If
ActiveRecord::Base.transaction
is called while already inside a transaction it does not create a "nested" transaction (actually a savepoint) c.f. Nested Transactions in the Rails documentationThis means the following code will lead to an incorrect state in the DB:
I actually ran into the opposite issue with aasm a while back, so the ideal solution would be to make the
requires_new
setting on the AR transaction configurable, c.f. aasm/aasm#107The text was updated successfully, but these errors were encountered: