Skip to content

Use TinyTDS Client#ping in active? when available - #1412

Draft
emailrhoads wants to merge 4 commits into
rails-sqlserver:mainfrom
emailrhoads:active-ping-via-tiny-tds
Draft

emailrhoads wants to merge 4 commits into
rails-sqlserver:mainfrom
emailrhoads:active-ping-via-tiny-tds

Conversation

@emailrhoads

@emailrhoads emailrhoads commented Sep 16, 2026

Copy link
Copy Markdown

Summary

  • When the TinyTDS client responds to #ping, SQLServerAdapter#active? uses a FreeTDS-bounded liveness round-trip (:ping_timeout, default 2 seconds) instead of relying only on passive dbdead / active?.
  • Set :ping_timeout to 0 to disable the checkout ping and keep the passive path.
  • Falls back to today’s passive @raw_connection.active? on TinyTDS builds without #ping.

Depends on / follows tiny_tds#609, which adds Client#ping(timeout:) + query_timeout=. This is the adapter-side policy for the checkout-liveness discussion in #1396: the driver owns the short-timeout probe; the adapter chooses to call it from active? (used by Rails 8 verify!).

This adapter used to do a live wellness check before #1121 (Oct 2023, “Removed legacy connection handling”), active? ran raw_connection_do "SELECT 1". That PR switched to TinyTDS’s passive active? / FreeTDS dbdead, which only flips after a failed I/O and therefore cannot detect an idle TCP RST (the peer closes the socket while the client still thinks the session is fine).

This restores checkout liveness in the spirit of the pre-#1121 SELECT 1 and of other adapters, without hanging on the connection’s timeout value, which may be much larger than is appropriate for this simple ping.

John Rhoads and others added 2 commits September 16, 2026 12:08
Idle RST leaves FreeTDS dbdead/active? stale-true until I/O fails. When
TinyTDS provides Client#ping (rails-sqlserver/tiny_tds#609), call it from
active? with a short FreeTDS-bounded timeout (config :ping_timeout, default 2s).
Older TinyTDS keeps the passive active? path.

Related to activerecord-sqlserver-adapter#1396.

Co-authored-by: Cursor <cursoragent@cursor.com>
Explicit zero must not fall through to the default; use the passive
active? path when ping is disabled or unavailable.

Co-authored-by: Cursor <cursoragent@cursor.com>
@emailrhoads
emailrhoads marked this pull request as draft September 16, 2026 18:10
Co-authored-by: Cursor <cursoragent@cursor.com>
@emailrhoads

Copy link
Copy Markdown
Author

Tracking issue: #1413

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant