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

Error after upgrading 5.1.5 to 5.2.0 on linux container #2385

Closed
pwasiewicz opened this issue Mar 4, 2024 · 5 comments
Closed

Error after upgrading 5.1.5 to 5.2.0 on linux container #2385

pwasiewicz opened this issue Mar 4, 2024 · 5 comments

Comments

@pwasiewicz
Copy link

pwasiewicz commented Mar 4, 2024

Describe the bug

We had connection string like this used in 5.1.5:

data source=my-server-domain,11222\SomeInstance;initial catalog=Database;persist security info=False;user id=my-user;password=my-pass;TrustServerCertificate=True;

After upgrading library to 5.2.0 we have experienced exception - but only when app was run on linux (from docker container using newest .NET 8 SDK image). The same code runs fine on Windows 11.

Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 26 - Error Locating Server/Instance Specified)
       ---> System.Net.Sockets.SocketException (0x80004005): Success
         at Microsoft.Data.SqlClient.SNI.SSRP.GetPortByInstanceName(String browserHostName, String instanceName, TimeoutTimer timeout, Boolean allIPsInParallel, SqlConnectionIPAddressPreference ipPreference)
         at Microsoft.Data.SqlClient.SNI.SNIProxy.CreateTcpHandle(DataSource details, TimeoutTimer timeout, Boolean parallel, SqlConnectionIPAddressPreference ipPreference, String cachedFQDN, SQLDNSInfo& pendingDNSInfo, Boolean tlsFirst, String hostNameInCertificate, String serverCertificateFilename)
         at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
         at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)
         at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, TimeoutTimer timeout, SqlConnectionString connectionOptions, Boolean withFailover)
         at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, TimeoutTimer timeout, Boolean withFailover)
         at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
         at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
         at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool, Func`3 accessTokenCallback)
         at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
         at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
         at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
         at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
         at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
         at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()

Downgrading to 5.1.5 solved issue.

To reproduce

From linux docker container:

await using var connection = new SqlConnection(/* conn here */);
await connection.OpenAsync();

Expected behavior

Connection opens w/o issues.

Further technical details

Microsoft.Data.SqlClient version: 5.2.0
.NET target: net8.0
SQL Server version: (e.g. SQL Server 2017): SQL Server 2019
Operating system: Docker container - mcr.microsoft.com/dotnet/aspnet:8.0

@JRahnama JRahnama added the 🆕 Triage Needed For new issues, not triaged yet. label Mar 4, 2024
@JRahnama
Copy link
Contributor

JRahnama commented Mar 4, 2024

@pwasiewicz can you test with default instance name to see if that works? What I want to be checked is DataSource without \ in it.

@David-Engel
Copy link
Contributor

Try changing your connection string to specify port OR named instance, not both.

@JRahnama JRahnama removed the 🆕 Triage Needed For new issues, not triaged yet. label Mar 5, 2024
@pwasiewicz
Copy link
Author

@pwasiewicz can you test with default instance name to see if that works? What I want to be checked is DataSource without \ in it.

Yes, it worked. We had other SQL Connection with port only and no issues here.

Try changing your connection string to specify port OR named instance, not both.

Is it for investigation purposes or workaround? That database is provided by customer, we cannot change to port or named instance "just like that". Connection to completely different sq; server works when using port only.

@David-Engel
Copy link
Contributor

Is it for investigation purposes or workaround? That database is provided by customer, we cannot change to port or named instance "just like that". Connection to completely different sq; server works when using port only.

Both. It confirms that specifying both port and instance name is the scenario that is broken, when running on Linux or macOS. Specifying only one or the other is the workaround. Previous behavior was to ignore the instance name if port is specified. Instance name is just a nice way to dynamically look up the port against the SQL Browser service anyway. We will be fixing this in a hotfix to 5.2.

@DavoudEshtehari
Copy link
Contributor

Addressed in #2395.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

4 participants