Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend activerecord and tinytds timeout?

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 ...

like image 782
ohho Avatar asked Oct 12 '25 16:10

ohho


1 Answers

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
like image 198
Mesut GUNES Avatar answered Oct 14 '25 06:10

Mesut GUNES



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!