-
Notifications
You must be signed in to change notification settings - Fork 424
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
[QUESTION] Exception is not thrown as expected when the session is killed in SQL database #1846
Comments
Hi, we'll do some investigating on our end and get back to you. |
I can not repro this issue when it's run against a local SQL Server as I do see a TDS_ERR reported and the driver will throw an exception that the session is in the Kill state. However when running against an Azure DB or a remote SQL Server there is just no error reported to the driver so there is nothing the driver can do as it doesn’t know there was a problem . It’s no different than if the network had gone down and the server has gone away eventually it will time out if there’s no response from the server and that’s all. In the code that's referenced when it tries to fetch the next fetch buffer it does check to see if there was a database error reported so if there was the driver will report the exception but if there was no error reported then there is nothing for the driver to do. |
depends on timing if the connection died you will see a connection reset |
Could you help explain the reasons in details? I'm a little confused why the error is not thrown when using spark, but would throw in some certain scenario, such as with the debug logs for jdbc jar is enabled? |
Hi @lilgreenbird , I have investigated the issue with the Databricks side. From the current findings, the issue may still persist with the newly released 11.2.0 version: https://github.com/microsoft/mssql-jdbc/releases/tag/v11.2.0 We have tried to only use Scala codes, which don’t involve Spark and just tries to call the library in the same way how Spark calls it. . After killing the session and giving only part of the records, but the error doesn’t show up. It could be the scenario when the error doesn't show up.
Could you help further look into it? Thanks in advance! |
Question
when using this library in Spark to run the SQL query and get the data into a Spark dataframe, if the session is accidentally killed from SQL database side, there's no reset error thrown as expected, but the count result has indicated that the data is not read completely.
steps to reproduce:
(1) use this library spark to run the SQL query and get the data into a Spark dataframe, code shown as below:
(2) kill the session from the SQL database side by "kill [SPID]"
(3) check the count() result, which is less than the actual one, but no error exception is thrown, the command is executed successfully.
Need help on
In general Spark connects to SqlServer and reads the data using the below code where rs is com.microsoft.sqlserver.jdbc.SQLServerResultSet, so whenever you killed the session rs.next() returned false but didn't throw the exception.
Based on the code analysis of com.microsoft.sqlserver.jdbc.SQLServerResultSet.next() there is a possibility that it returns false when the connection is broken, You can refer the code here https://github.com/microsoft/mssql-jdbc/blob/main/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java#L1011-L1107
Could you help check why the exception is not thrown as expected? Thanks!
The text was updated successfully, but these errors were encountered: