mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
The problem isn't the detection but the deadlock itself
This commit is contained in:
parent
4f5a9890b7
commit
ac76d551ce
5 changed files with 10 additions and 10 deletions
|
@ -753,7 +753,7 @@ module ActiveRecord
|
|||
when ER_DATA_TOO_LONG
|
||||
ValueTooLong.new(message)
|
||||
when ER_LOCK_DEADLOCK
|
||||
DeadlockDetected.new(message)
|
||||
Deadlocked.new(message)
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
|
@ -407,7 +407,7 @@ module ActiveRecord
|
|||
FOREIGN_KEY_VIOLATION = "23503"
|
||||
UNIQUE_VIOLATION = "23505"
|
||||
SERIALIZATION_FAILURE = "40001"
|
||||
DEADLOCK_DETECTED = "40P01"
|
||||
DEADLOCKED = "40P01"
|
||||
|
||||
def translate_exception(exception, message)
|
||||
return exception unless exception.respond_to?(:result)
|
||||
|
@ -421,8 +421,8 @@ module ActiveRecord
|
|||
ValueTooLong.new(message)
|
||||
when SERIALIZATION_FAILURE
|
||||
SerializationFailure.new(message)
|
||||
when DEADLOCK_DETECTED
|
||||
DeadlockDetected.new(message)
|
||||
when DEADLOCKED
|
||||
Deadlocked.new(message)
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
|
@ -300,9 +300,9 @@ module ActiveRecord
|
|||
class SerializationFailure < TransactionRollbackError
|
||||
end
|
||||
|
||||
# DeadlockDetected will be raised when a transaction is rolled
|
||||
# Deadlocked will be raised when a transaction is rolled
|
||||
# back by the database when a deadlock is encountered.
|
||||
class DeadlockDetected < TransactionRollbackError
|
||||
class Deadlocked < TransactionRollbackError
|
||||
end
|
||||
|
||||
# IrreversibleOrderError is raised when a relation's order is too complex for
|
||||
|
|
|
@ -27,8 +27,8 @@ module ActiveRecord
|
|||
@connection.drop_table 'samples', if_exists: true
|
||||
end
|
||||
|
||||
test "raises DeadlockDetected when a deadlock is encountered" do
|
||||
assert_raises(ActiveRecord::DeadlockDetected) do
|
||||
test "raises Deadlocked when a deadlock is encountered" do
|
||||
assert_raises(ActiveRecord::Deadlocked) do
|
||||
s1 = Sample.create value: 1
|
||||
s2 = Sample.create value: 2
|
||||
|
||||
|
|
|
@ -58,9 +58,9 @@ module ActiveRecord
|
|||
end
|
||||
end
|
||||
|
||||
test "raises DeadlockDetected when a deadlock is encountered" do
|
||||
test "raises Deadlocked when a deadlock is encountered" do
|
||||
with_warning_suppression do
|
||||
assert_raises(ActiveRecord::DeadlockDetected) do
|
||||
assert_raises(ActiveRecord::Deadlocked) do
|
||||
s1 = Sample.create value: 1
|
||||
s2 = Sample.create value: 2
|
||||
|
||||
|
|
Loading…
Reference in a new issue