microsoft/mssql-jdbc

NullPointerException on reconnect with lockTimeout configured

HeinzHuberRsg opened this issue · 5 comments

Driver version

10.2.3 - 12.6.0

SQL Server version

2019

Client Operating System

Windows, Linux

JAVA/JVM version

1.8.0, 17

Table schema

No special schema

Problem description

If an automatic reconnect is triggered and lockTimeout is configured, a NullPointerException is thrown.

Expected behavior

Automatic reconnect works.

Actual behavior

Reconnect fails.

Error message/stack trace

Exception in thread "Thread-0" java.lang.NullPointerException: Cannot invoke "com.microsoft.sqlserver.jdbc.ICounter.increaseCounter(long)" because the return value of "com.microsoft.sqlserver.jdbc.TDSCommand.getCounter()" is null
at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6880)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:8077)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:8040)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$1ConnectionCommand.doExecute(SQLServerConnection.java:4260)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7675)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeReconnectCommand(SQLServerConnection.java:4222)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(SQLServerConnection.java:4266)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:5163)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:5087)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7675)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeReconnect(SQLServerConnection.java:3590)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3571)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:3172)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:3018)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1836)
at com.microsoft.sqlserver.jdbc.ReconnectThread.run(IdleConnectionResiliency.java:461)

Any other details that can be helpful

JDBC trace logs

jdbc0.zip
The support case 2402210030004759 contains an app to reproduce the problem

Thank you for providing additional instructions to what was mentioned in 2402210030004759. Since this is the same issue, we will be providing updates in that email thread.

Well. The NPE has gone away. But still no reconnect!
Should we file another issue or can this one be reopened?

The above reconnection issue is part of a broader series of issues with reconnection/retry with the driver. We plan on releasing larger changes to address all these issues at once. If, following the release, the issue you have above persists, then please open a new issue. However, we do plan on including the above scenario in our test suite for the aforementioned retry changes. We will update this thread when the above changes are released.

Thx for the information.
Looking forward to the bigger fixes then ;)

@HeinzHuberRsg I've continued the discussion at #2438, reserving this closed issue for just the NullPointerException. I have a question though, what connection string options, besides lockTimeout do you have configured? It would be best if you could share your connection string with us.