Skip to content

Commit

Permalink
Merge pull request #48780 from rails/ar-deadlocked
Browse files Browse the repository at this point in the history
Improve the docs of ActiveRecord::TransactionRollbackError
  • Loading branch information
fxn committed Sep 15, 2023
2 parents 9e4d9c4 + b70571c commit 29cb2ba
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions activerecord/lib/active_record/errors.rb
Expand Up @@ -483,6 +483,19 @@ class TransactionIsolationError < ActiveRecordError
# TransactionRollbackError will be raised when a transaction is rolled
# back by the database due to a serialization failure or a deadlock.
#
# These exceptions should not be generally rescued in nested transaction
# blocks, because they have side-effects in the actual enclosing transaction
# and internal Active Record state. They can be rescued if you are above the
# root transaction block, though.
#
# In that case, beware of transactional tests, however, because they run test
# cases in their own umbrella transaction. If you absolutely need to handle
# these exceptions in tests please consider disabling transactional tests in
# the affected test class (<tt>self.use_transactional_tests = false</tt>).
#
# Due to the aforementioned side-effects, this exception should not be raised
# manually by users.
#
# See the following:
#
# * https://www.postgresql.org/docs/current/static/transaction-iso.html
Expand All @@ -497,11 +510,17 @@ class AsynchronousQueryInsideTransactionError < ActiveRecordError

# SerializationFailure will be raised when a transaction is rolled
# back by the database due to a serialization failure.
#
# This is a subclass of TransactionRollbackError, please make sure to check
# its documentation to be aware of its caveats.
class SerializationFailure < TransactionRollbackError
end

# Deadlocked will be raised when a transaction is rolled
# back by the database when a deadlock is encountered.
#
# This is a subclass of TransactionRollbackError, please make sure to check
# its documentation to be aware of its caveats.
class Deadlocked < TransactionRollbackError
end

Expand Down

0 comments on commit 29cb2ba

Please sign in to comment.