-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout does not work when tcp packets are dropped #445
Comments
Interesting, definitely seems like a bug at first glace. From your log, the timeout error is 20003, which corresponds to SYBETIME, which has special consideration here: https://github.com/rails-sqlserver/tiny_tds/blob/master/ext/tiny_tds/client.c#L83-L91 Random idea: the error is getting handled by tinytds, and stored in the You could test this idea by adding some logging to |
Thanks. I did as you suggested, and it looks like what you described is occurring. Here are three iterations of logs I added to tinytds_err_handler. main.rb:15: warning: Entering tinytds_err_handler main.rb:15: warning: Entering tinytds_err_handler main.rb:15: warning: Entering tinytds_err_handler |
Scenario: Switching from a primary to a backup network, the firewall invalidates all existing tcp sessions and starts dropping packets.
Expected results: Configured timeout is hit and tiny_tds reports an error
Actual results: No response from tiny_tds until underlying tcp connection's retries expire (> 15 minutes on Ubuntu, for example: https://pracucci.com/linux-tcp-rto-min-max-and-tcp-retries2.html)
Simple sample code attached in timeout.zip file. You'll need to simulate dropped packets in order to see the issue, which is shown about halfway down the attached freetds.log. Freetds reports a timeout in the log, over and over and over, but tiny_tds does not return any error to the caller. I am not sure if the issue is actually with tiny_tds or freetds.
Steps to reproduce:
dump file = /tmp/freetds.log
debug flags = 0xffff
iptables -I INPUT -s 1.2.3.4 -j DROP (where 1.2.3.4 is your db's ip address)
block drop from 1.2.3.4 to any (where 1.2.3.4 is your db's ip address)
At this point you should see the repeatedly ignored timeouts in freetds.log. On Linux this will continue for over 15 minutes before the connection finally times out. On Mac it takes around 30 seconds.
You can restore your connection by replacing DROP with ACCEPT for iptables, or by removing the extra line from pf.conf and running pfctl again.
freetds.log
timeout.zip
The text was updated successfully, but these errors were encountered: