JDK-7106332 : MSSQL JDBC Driver (Type4) deadlock while establishing connection
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 6u26
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-10-29
  • Updated: 2012-03-20
  • Resolved: 2011-11-11
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java -version
java version "1.6.0_30-ea"
Java(TM) SE Runtime Environment (build 1.6.0_30-ea-b10)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 7 (x64) Ultimate SP1

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested in several different network scenarios:
- Direct LAN connect
- via VPN
- With and without Domain Membership
- SQL-Server with Windows Authentication and also Username/password authentication was tested.

A DESCRIPTION OF THE PROBLEM :
In Java Runtime Version 6u30
Microsoft's SQL-Server JDBC Driver stops working because of a deadlock.
(6u29 also shows this behavior)

See the stacktrace below for the exact deadlock location.

In Java Runtime 6u26 and before (tested since version 6u3) the problem does not exist. Java Runtime 7u1 also works without issues.

Versions of MS JDBC driver tested:
- MSSQL JDBC Type4 Version 2.0
- MSSQL JDBC Type4 Version 3.0
- MSSQL JDBC Type4 Version 4.0 (CTP3)

against SQL Server Express 2008 SP2 and SP3.

All versions of Micrsosoft's JDBC driver show exactly the same behavior.
The type of authentication (integrated or not) does not impact the deadlock. Neither does the presence of the driver's native libraries.

Attached below please find:
- The stracktrace of the deadlock
- Log output from microsoft's driver



REGRESSION.  Last worked in version 6u26

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Construct a simple JDBC connection as shown here:

http://msdn.microsoft.com/de-de/library/ms378428.aspx

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Connection should be established
ACTUAL -
Deadlock occurs in the middle of connection establishment

ERROR MESSAGES/STACK TRACES THAT OCCUR :
- The stracktrace of the deadlock
- Log output from microsoft's driver

"Thread-4" - Thread t@19
   java.lang.Thread.State: RUNNABLE
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(Unknown Source)
	at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1736)
	at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:4716)
	- locked <7fac4f3e> (a com.microsoft.sqlserver.jdbc.TDSReader)
	at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6021)
	at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:5973)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2907)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2242)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2228)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5574)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1734)
	- locked <69c9de24> (a java.lang.Object)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1355)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1022)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:858)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at de.m1b.tool2.util.PropsDataSource.getConnection(PropsDataSource.java:103)
	at de.m1b.tool2.util.PropsDataSource.getConnection(PropsDataSource.java:47)
	at de.m1b.conzept.creator.KundenReader.doTheJob(KundenReader.java:95)
	at de.m1b.tool2.util.ListWorkerBean.prepareRun(ListWorkerBean.java:143)
	at de.m1b.tool2.util.ListWorkerBean$1$1.run(ListWorkerBean.java:62)

   Locked ownable synchronizers:
	- None



11:59:48.343 WARN de.m1b.conzept.creator.KundenReader - Status: Connecting BCM Database...

11:59:48.345 FINE ..er.jdbc.internals.SQLServerDriver - Property:serverName Value:sqlserver.contoso.com

11:59:48.345 FINE ..er.jdbc.internals.SQLServerDriver - Property:instanceName Value:EXPR2008_BCM

11:59:48.345 FINE ..er.jdbc.internals.SQLServerDriver - Property:databaseName Value:BCM2010

11:59:48.345 FINE ..er.jdbc.internals.SQLServerDriver - Property:integratedSecurity Value:true

11:59:48.354 FINE ..dbc.internals.SQLServerConnection - ConnectionID:1 created by (SQLServerDriver:1)

11:59:48.359 FINE ..dbc.internals.SQLServerConnection - ConnectionID:1 This attempt server name: sqlserver.contoso.com port: 5356 InstanceName: EXPR2008_BCM2010 useParallel: false

11:59:48.359 FINE ..dbc.internals.SQLServerConnection - ConnectionID:1 This attempt endtime: 1319882403355

11:59:48.359 FINE ..dbc.internals.SQLServerConnection - ConnectionID:1 This attempt No: 0

11:59:48.359 FINE ..dbc.internals.SQLServerConnection - ConnectionID:1 Connecting with server: sqlserver.contoso.com port: 5356 Timeout slice: 14996 Timeout Full: 15

11:59:48.374 FINE ..dbc.internals.SQLServerConnection - ConnectionID:1 ClientConnectionId: d6e5bd7c-78b1-4642-9694-84d88d19f112 Server returned major version:10

11:59:48.569 FINE ...jdbc.internals.AuthenticationJNI - Init pacakage is called

11:59:48.569 FINE ...jdbc.internals.AuthenticationJNI - szDllFileName: 'secur32.dll'

11:59:48.574 FINE ...jdbc.internals.AuthenticationJNI - SPNInit

11:59:48.574 FINE ...jdbc.internals.AuthenticationJNI - szDllFileName: 'ntdsapi.dll'

11:59:48.575 FINE ...jdbc.internals.AuthenticationJNI - SPNInit success

11:59:48.575 FINE ...jdbc.internals.AuthenticationJNI - SNISecInitPacakge successful

11:59:48.575 FINE ...jdbc.internals.AuthenticationJNI - sqlserver.contoso.com

11:59:48.575 FINE ...jdbc.internals.AuthenticationJNI - GetDnsName

11:59:48.587 FINE ...jdbc.internals.AuthenticationJNI - GetDnsName success

11:59:48.587 FINE ...jdbc.internals.AuthenticationJNI - AuthenticationJNI_SNISecGenClientContext called

11:59:48.587 FINE ...jdbc.internals.AuthenticationJNI - sqlserver.contoso.com

11:59:48.587 FINE ...jdbc.internals.AuthenticationJNI - MSSQLSvc/sqlserver.contoso.com:5356

11:59:48.587 FINE ...jdbc.internals.AuthenticationJNI - MSSQLSvc/sqlserver.contoso.com:5356

11:59:48.588 FINE ...jdbc.internals.AuthenticationJNI - Calling the SNISecGenClientContext


11:59:48.588 FINE ...jdbc.internals.AuthenticationJNI - SNISecGenClientContext called

11:59:48.588 FINE ...jdbc.internals.AuthenticationJNI - negotiate

11:59:48.588 FINE ...jdbc.internals.AuthenticationJNI - MSSQLSvc/sqlserver.contoso.com:5356

11:59:48.588 FINE ...jdbc.internals.AuthenticationJNI - SEC Init succeeded

11:59:48.594 FINE ...jdbc.internals.AuthenticationJNI - AuthenticationJNI_SNISecGenClientContext called

11:59:48.594 FINE ...jdbc.internals.AuthenticationJNI - sqlserver.contoso.com

11:59:48.594 FINE ...jdbc.internals.AuthenticationJNI - MSSQLSvc/sqlserver.contoso.com:5356

11:59:48.594 FINE ...jdbc.internals.AuthenticationJNI - MSSQLSvc/sqlserver.contoso.com:5356

11:59:48.595 FINE ...jdbc.internals.AuthenticationJNI - Calling the SNISecGenClientContext


11:59:48.595 FINE ...jdbc.internals.AuthenticationJNI - SNISecGenClientContext called

11:59:48.595 FINE ...jdbc.internals.AuthenticationJNI - negotiate

11:59:48.595 FINE ...jdbc.internals.AuthenticationJNI - MSSQLSvc/sqlserver.contoso.com:5356

11:59:48.595 FINE ...jdbc.internals.AuthenticationJNI - SEC Init succeeded
[Here is the deadlock]



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Can be provided on demand, but simplest jdbc sample suffices.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use JRE 7