Skip to content

Changed handling of dead connections #2

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

Conversation

aidanharan
Copy link

Suggested changes related to rails-sqlserver#903:

  1. Do not check if a connection is dead/alive before using it. Using connection.active? would mean an extra call to the database for every query. We will know whether the connection is dead based on whether TinyTds::Error("failed to execute statement") is thrown. Removed !@connection.active? from https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/903/files#diff-f749b206a3bbfaa7e02aa77f1c26715bea21134aa6d2645cbf9068783e280cf8R467

  2. If a connection is disconnected or dead then a ConnectionNotEstablished should be thrown. The disconnection part is already done. We just need to check if the connection was dead. This can be detected by checking for the "failed to execute statement" error message when translating the exception (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/903/files#diff-3562da8bff63a7b06dce2a8b9e1163ab5598cca3bcaaf1b971a1c3e40942b053R378).

@aidanharan aidanharan changed the title Raise connection not established dead Changed handling of dead connections Apr 26, 2021
@aidanharan aidanharan changed the base branch from main to issues/yellowspot/rails-6-1/raise-connection-not-established April 26, 2021 15:35
@aidanharan aidanharan marked this pull request as ready for review April 26, 2021 15:35
@mgrunberg mgrunberg deleted the branch yellowspot:issues/yellowspot/rails-6-1/raise-connection-not-established January 3, 2022 17:31
@mgrunberg mgrunberg closed this Jan 3, 2022
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