I have the following code in which a deadlock exception is rescued. In that rescue, I modify another record and save it. That save doesn't go through.
Is a transaction within rescue
a nested transaction of the transaction in the begin
?
begin
Something.transaction do
something.save # this causes a deadlock
end
rescue StandardError => se
# This gets called while rescuing a deadlock
some_record.status = "updating"
some_record.save # this seems to get rolled back
puts se.error_message # Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction:
end
Aucun commentaire:
Enregistrer un commentaire