Skip to content
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

Nullreference error when failoverpartner is set #587

Closed
gunnarif opened this issue Jun 2, 2020 · 1 comment · Fixed by #588
Closed

Nullreference error when failoverpartner is set #587

gunnarif opened this issue Jun 2, 2020 · 1 comment · Fixed by #588
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain.

Comments

@gunnarif
Copy link

gunnarif commented Jun 2, 2020

If "Failover Partner" is set in the connection string sql client fails with null reference error

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.Data.SqlClient
  StackTrace:
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(Boolean useFailoverHost, ServerInfo primaryServerInfo, String failoverHost, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) in D:\Projects\SqlClient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 1654
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) in D:\Projects\SqlClient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 1299

  This exception was originally thrown at this call stack:
    Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(bool, Microsoft.Data.SqlClient.ServerInfo, string, string, System.Security.SecureString, bool, Microsoft.Data.SqlClient.SqlConnectionString, Microsoft.Data.SqlClient.SqlCredential, Microsoft.Data.ProviderBase.TimeoutTimer) in SqlInternalConnectionTds.cs
    Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(Microsoft.Data.ProviderBase.TimeoutTimer, Microsoft.Data.SqlClient.SqlConnectionString, Microsoft.Data.SqlClient.SqlCredential, string, System.Security.SecureString, bool) in SqlInternalConnectionTds.cs

Looking at the source code RoutingInfo is being used when it is null.

To reproduce

Set failover partner in the connection string
Using sql server 2012, don't know if that has any affect

Expected behavior

Connect to sql server

Further technical details

Current source
.NET target: DotCore 3.1
SQL Server version: SQL Server 2012
Operating system: Windows 10

@DavoudEshtehari DavoudEshtehari added the 🐛 Bug! Issues that are bugs in the drivers we maintain. label Jun 2, 2020
@DavoudEshtehari
Copy link
Contributor

Thank you @gunnarif for informing us.
Also, there is another issue related to failoverpartner is under investigation at #583

It is reproducible in Netcore with the following details, And NetFx does not reproduce it.

ManagedSNI: false/true

NetCore 3.1.4

Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2 (X64)   Jun 15 2019 00:26:19   Copyright (C) 2017 Microsoft Corporation  Developer Edition (64-bit) on Windows 8.1 Enterprise 6.3 <X64> (Build 9600: ) (Hypervisor)

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.18362 N/A Build 18362

stack trace:
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(Boolean useFailoverHost, ServerInfo primaryServerInfo, String failoverHost, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants