Add Client#ping(timeout:) for FreeTDS-bounded liveness checks - #609
Open
emailrhoads wants to merge 1 commit into
Open
emailrhoads wants to merge 1 commit into
emailrhoads wants to merge 1 commit into
Conversation
Temporarily lower DBSETTIME for SELECT 1 so dead/idle-RST handles fail in seconds instead of the connection's long query timeout; restore on success. Returns false on failure so callers can discard the client. Addresses the liveness-probe discussion in rails-sqlserver/activerecord-sqlserver-adapter#1396 without changing passive active?/dead? semantics. Co-authored-by: Cursor <cursoragent@cursor.com>
Author
|
Tracking discussion / attention request on the adapter side: rails-sqlserver/activerecord-sqlserver-adapter#1413 (also links this PR and adapter #1412). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TinyTds::Client#ping(timeout:)that temporarily sets FreeTDSDBSETTIME, runsSELECT 1, restores the previous timeout on success, and returnsfalseon timeout/failure so callers can discard the handle.query_timeout/query_timeout=(shared helper also used at connect) so a live client can change query timeout without reconnecting.active?/dead?(dbdead) — explicit#pingkeeps the opt-in clear for adapters/apps.This is meant as the driver-level answer to the checkout-liveness question in activerecord-sqlserver-adapter#1396: idle TCP RST (TCP reset — peer or middlebox abruptly closes the socket while the client still believes the session is alive) plus passive FreeTDS
dbdead. RubyTimeoutaroundexecutedoes not reliably interrupt TinyTDS/C I/O; the short bound has to be FreeTDS-level. Policy for when to call#ping(e.g. adapterverify!/active?) can live in the adapter — see follow-up activerecord-sqlserver-adapter#1412.Test plan
bundle exec rake compiletest/client_test.rb:query_timeoutfrom connect;query_timeout=bounds WaitFor;#pingreturns true and restores timeout;#pingreturns false when round-trip exceeds ping timeout; ArgumentError / closed client cases