Ruby Rails Mongrel Server ODBC Connection Reset

I am currently running ruby ​​on rails (ruby 1.8.7, rails 2.3.8) on a Windows 2008 server in IIS7. I use mongrel rails to run instances, and then add instances to the server farm in IIS7 to use.

When the application is started and somehow the connection to the database server is dropped, it seems that the rails application is still trying to connect using the ODBC connection, and I get the following error:

ActiveRecord::StatementInvalid (ODBC::Error: S0002 (208) [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'sessions_table'.: SELECT TOP 1 * FROM [sessions_table] WHERE ([sessions_table].[session_id] = 'e6a7e7bc3b72edf2662c2b97793694d2') ): vendor/gems/activerecord-sqlserver-adapter-2.3.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:946:in `raw_select' vendor/gems/activerecord-sqlserver-adapter-2.3.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:923:in `select' app/controllers/application_controller.rb:107:in `set_locale' haml (3.0.17) [v] lib/sass/plugin/rack.rb:41:in `call' haml (3.0.17) [v] lib/sass/plugin/rack.rb:41:in `call' config/initializers/mongrel.rb:62:in `dispatch_cgi' 

This error disappears when I restart the mongrel services, however I would really like the application to recognize the odbc error and reset the connection automatically. Any ideas?

+4
source share
2 answers

If you are sure that your table name is correct, check how you defined it in your model. The definition should contain the database name and schema name (usually "dbo").

For Rails 2.xx, this will be:

 set_table_name "database_name.dbo.table_name" 

And for Rails> = 3.xx:

 self.table_name = "database_name.dbo.table_name" 
+1
source

You can catch this exception and try to reconnect! ?

Once reset (RST?) Occurs, its the likelihood that adapter implantation now has an invalid connection or connection pool. I wonder if reconnect! will reset the connection / connection pool and allow the client to continue gracefully. Or at least try [n] again before giving up.

NTN

Z

0
source

All Articles