Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFixed "fake" nested transactions swallowing manual rollbacks #15017
Conversation
arthurnn
reviewed
May 7, 2014
activerecord/test/cases/transactions_test.rb
| @first.approved = true | ||
| @first.save! | ||
| Topic.transaction :requires_new => true do |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
@rafaelfranca do you think it's okay to change this on 4.2? |
chancancode
added some commits
May 7, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
chancancode
May 8, 2014
Member
|
|
rafaelfranca
added
the
activerecord
label
May 19, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
Does #16284 take care of the issue this was trying to address? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
chancancode
Oct 8, 2014
Member
@maxfelsher no, this is a deeper issue that requires more refactoring :/
|
@maxfelsher no, this is a deeper issue that requires more refactoring :/ |
chancancode
closed this
Oct 8, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
Since this PR is not ready, closing for now. cc @arthurnn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chancancode commentedMay 7, 2014
Previously,
ActiveRecord::Rollbackare silently swallowed by all transactionblocks. The intention behind this is that these special "exceptions" are only
used to signal a rollback request to Active Record, thus they should be
discarded after the rollback request is handled.
However, this is incorrect for nested transactions. By default, nested
transaction blocks are effectively a no-op – they simply become part of the
parent transaction†. To achieve this, the correct behaviour is to "bubble up"
the
ActiveRecord::Rollback"exception", which allow the first parenttransaction block with a real database transaction to correctly handle the
rollback.
The documentation has been changed to reflect this. This effectively rolls
back 53bbbcc.
Fixes #3455, #14698.
† The reason that nested transactions defaults to no-op is that savepoints are
not supported in all databases.
Godfrey Chan
This "bug" was around since forever, so this is definitely a change in behaviour. I doubt that anyone is relying on the current behaviour though.
cc @tenderlove @jeremy @fxn @arthurnn @senny