rails-sqlserver/activerecord-sqlserver-adapter — pull request #365 by rolftimmermans (2014-11-25 16:23:58+00:00)
Title: Persistent connection errors during failover or with networking issues when executing stored procedures

I am having issues with an application that makes extensive use of code such as:

connection.execute_procedure(:fooBar, ...)

After a network or database node failure, errors are thrown in the application that subsequently do not go away. Also, the connection is reported as active after such an error has occurred:

connection.active? #=> true

The errors often look like this:

TinyTds::Error: DBPROCESS is dead or not enabled: EXEC fooBar

When looking at the code, it seems to me that a call to `with_sqlserver_error_handling` is missing in this function:

https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/604083bfd5fa8986e56ac0d54480a850d47b2cc0/lib/active_record/connection_adapters/sqlserver/database_statements.rb#L84-L115

Wrapping the method in `with_sqlserver_error_handling do ... end` does indeed appear to fix the issue.

Am I on the right track? If so, I'll submit a PR.