How to extend activerecord and tinytds timeout?

2.7k Views Asked by At

The symptom is:

TinyTds::Error: Adaptive Server connection timed out: EXEC some_stored_procedure

It's execute_procedure a slow stored procedure on a slow MSSQL Server via ActiveRecord over tinytds. If I EXEC the stored procedure in SQL Query Analyzer, it takes 29 to 30 to finish.

So I added:

timeout = 60

in /etc/freetds.conf and:

read_timeout: 60
write_timeout: 60

to database.yml.

The same error still shows up. Is there any other configs I missed?

p.s. I did measure when the timeout error shows up with a timer after hitting return key, it's about 30 seconds. I have a feeling 30 seconds may not be the default timeout of freetds or activerecord and wonders why the error shows up somewhat close the time for the sql to finish ...

1

There are 1 best solutions below

1
On

It has been pretty long time but someone may need this. I solved this by passing timeout: option for creating tiny_tds client depend on git doc, see the below:

client = TinyTds::Client.new username: 'sa', password: 'secret', host: 'mydb.host.net', timeout: 30