Skip to content

Treat TinyTDS failed dbsqlsend() errors as ConnectionNotEstablished - #1393

Merged
aidanharan merged 1 commit into
rails-sqlserver:mainfrom
justindell:fix/dbsqlsend-connection-not-established
Jul 29, 2026
Merged

Treat TinyTDS failed dbsqlsend() errors as ConnectionNotEstablished#1393
aidanharan merged 1 commit into
rails-sqlserver:mainfrom
justindell:fix/dbsqlsend-connection-not-established

Conversation

@justindell

Copy link
Copy Markdown
Contributor

TinyTDS can raise failed dbsqlsend() function when the underlying FreeTDS socket has dropped. This happens when an idle connection gets reaped by network infrastructure or by SQL Server itself.

translate_exception doesn't recognize this message right now, so it falls through to StatementInvalid. ActiveRecord's connection pool doesn't treat that as reconnectable, so callers get a hard query failure instead of a transparent reconnect and retry.

This is the same failure mode already handled for "SQL Server client is not connected" and "failed to execute statement". I added failed dbsqlsend to that same pattern so it maps to ActiveRecord::ConnectionNotEstablished too.

@aidanharan
aidanharan merged commit 40b3fa6 into rails-sqlserver:main Jul 29, 2026
5 checks passed
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.

2 participants