-
Notifications
You must be signed in to change notification settings - Fork 562
Retry deadlock victim error #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry deadlock victim error #150
Conversation
… retrying the query. Add SQLServerAdapter.retry_deadlock_victim option to disable this handling.
…bstract/database_statements.rb for adding in handling of deadlock victim exception.
…g the rollback_db_transaction (since SQL Server issues it automatically) and retry the whole transaction if the retry_deadlock_victim flag is enabled (default).
|
Real clean code! I Love the new WrappedDatabaseException too! Now that I have looked at the monkey patch for #transaction, I am getting cold feet. Perhaps we could do the following to make this less brittle for the core adapter without this configuration. Here are a few suggestion, would love your thoughts on these:
module ActiveRecord
module ConnectionAdapters
module Sqlserver
module DatabaseStatements
def transaction(options = {})
retry_deadlock_victim? ? transaction_with_retry_deadlock_victim(options) : super
end
def transaction_with_retry_deadlock_victim(options = {})
# Our copy of transaction here.
end
end
end
end
end
Notes to self:
|
… method, otherwise, call our version of the transcation method with deadlock_victim retry logic.
…at it handles both dropped connections and deadlock victim errors.
for most if not all queries we want to retry, so assume it has been translated.
|
@metaskills, I removed the extra translate_exception call in transaction_with_retry_deadlock_victim since log would raise to us the translated exception for nearly all of the queries we would ever want to retry as part of a transaction. I did not remove the translate_exception call in #with_sqlserver_error_handling since it's called within the log block and the exception would not yet be translated. |
Retry deadlock victim error
|
Please QA my work. All tests still green. |
|
Looks good from a quick review, I'll do more testing in the next few days when I incorporate these changes and will let you know if I have any issues. Was there something that specifically needing AR ~> 3.1.3 instead of ~> 3.1.0? Just wondering since transaction does not appear to be different between those tags. |
|
Whoops, that gemspec change was a mistake on my part. |
No description provided.