You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.7.0 :001 > Pratica.count
SQL (17.4ms) USE [WinLEG]
(18.0ms) SELECT COUNT(*) FROM [Pratiche]
=> 10854
... Waiting 30seconds here, then
2.7.0 :002 > Pratica.count
/home/developer/.rvm/gems/ruby-2.7.0/gems/activerecord-sqlserver-adapter-6.1.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:461: warning: TinyTds: dbsqlsend() returned FAIL.
(1.9ms) SELECT COUNT(*) FROM [Pratiche]
Traceback (most recent call last):
1: from (irb):2
ActiveRecord::ConnectionNotEstablished (TinyTds::Error: failed to execute statement)
2.7.0 :003 > Pratica.count
(0.4ms) SELECT COUNT(*) FROM [Pratiche]
Traceback (most recent call last):
2: from (irb):2
1: from (irb):3:in `rescue in irb_binding'
ActiveRecord::StatementInvalid (TinyTds::Error: DBPROCESS is dead or not enabled)
2.7.0 :004 > Pratica.connection
=> #<ActiveRecord::ConnectionAdapters::SQLServerAdapter version: 6.1.2.1, mode: dblib, azure: false>
...
2.7.0 :009 > Pratica.connection.reconnect!
SQL (17.8ms) USE [WinLEG]
=> -1
2.7.0 :010 > Pratica.count
(19.1ms) SELECT COUNT(*) FROM [Pratiche]
=> 10854
2.7.0 :011 >
Expected behavior
It should reconnect automatically. Is there a way to configure this? I checked the code and it seems that "reconnect" option is not used.
This case seems related to #623 but I don't see a solution. Is there a way to force automatic reconnection?
How to reproduce
app/model/pratica.rb:
class Pratica < ActiveRecord::Base
self.abstract_class
self.table_name = 'Pratiche'
self.primary_key = 'pra_ID'
end
What happened between you first ran Pratica.count and the second time you tried to execute the same query? Was the database restarted or something like that?
Unrelated, but why do you call self.abstract_class in your class? That should probably be removed.
Unfortunately, I have only read permissions on the database and it seems to me that the script you linked needs to create and drop a table. Is there something else I can do?
As a side note, I can say that I have the issue only from the rails console. My application actually works, probably because the connection is re-established automatically when I use the web app.
Issue
Hi, here is a description of my issue:
... Waiting 30seconds here, then
Expected behavior
It should reconnect automatically. Is there a way to configure this? I checked the code and it seems that "reconnect" option is not used.
This case seems related to #623 but I don't see a solution. Is there a way to force automatic reconnection?
How to reproduce
app/model/pratica.rb:
configu/database.yml:
Details
Rails version:
6.1.4.4
SQL Server adapter version:
6.1.2.1
TinyTDS version:
2.1.5
FreeTDS details:
The text was updated successfully, but these errors were encountered: