SqlClient: SqlConnection.Open() throws System.InvalidOperationException: Internal connection fatal error on alpine
I get the error below when connecting to a SQL Server 2008R2 using the microsoft/dotnet:2.1.0-preview2-runtime-alpine docker image, but it works fine with microsoft/dotnet:2.1.0-preview2-runtime.
System.InvalidOperationException: Internal connection fatal error.
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
[...my code..]
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
[...my code..]
Boolean TryGetConnection(System.Data.Common.DbConnection, UInt32, Boolean, Boolean, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal ByRef)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 47 (15 by maintainers)
Commits related to this issue
- Fix libs https://github.com/dotnet/corefx/issues/29147 — committed to imdocker/dotnet-core3 by imdocker 6 years ago
- Merged PR 1627: Detect and throw Exception for Globalization Invariant Mode Addressing github issue 81: SqlConnection.Open() throws System.InvalidOperationException: Internal connection fatal error o... — committed to JRahnama/SqlClient by David-Engel 5 years ago
I have the same problem. I installed the package icu-libs and set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
Example
It works for microsoft/dotnet:2.1-aspnetcore-runtime-alpine
@AfsanehR can you please look into how we can we make sure that:
@benmccallum accord to earlier comment you can detect the invariant mode by calling
If invariant is true, you will need to get the globalization library as mentioned above.
To confirm, if upgrading to ASP.NET Core 3.0 and 3.0-alpine images, this issue is still present and the workaround needs to be applied? Doing an upgrade now and would be good to drop the size if possible.
@karelz It was the
microsoft/dotnet:2.1-runtime-alpine
image that I had to update with the following to resolve the issue.I assumed the need to add
icu-libs
and set theDOTNET_SYSTEM_GLOBALIZATION_INVARIANT
environment variable was a temporary workaround for the issue, and that future images would be updated to remove the need for this.@karelz yes, this is not a SqlClient issue. Either the base image of the docker file should be updated to have the icu-libs or the Dockerfile, for instance here , needs to have the following two lines suggested earlier.
As a temporary workaround I managed to get it running by switching the runtime stage image from
microsoft/dotnet:2.1-aspnetcore-runtime-alpine
to one of my creation.Dockerhub: https://hub.docker.com/r/mjedynski/aspnetcore-paxmarked/ Source code: https://github.com/marcin-jedynski/aspnetcore-paxmarked
It’s built on top of regular
microsoft/dotnet:2.1-aspnetcore-runtime
and contains of modified bypaxctl
dotnet binary.The same application runs inside it without any problems. @hpbieker @AfsanehR could you test your application running on my image ?
@AfsanehR I too can confirm that @kihamo’s workaround resolved the issue. Based on the
3.0
milestone added by @karelz is it safe to assume that the image will be updated with the necessary changes in the future despite the issue being closed?I can confirm that the issue is resolved for us to. Sorry for the delay.
El mié., 27 jun. 2018 23:21, Afsaneh Rafighi notifications@github.com escribió:
I am having the exact same problem running apps based on the 2.1-runtime-alpine image on a CoreOs Docker Host. I am willing to dig up all of the relevant info and share it, what exactly do you need?
Edit I: Here’s what I am using:
Docker version 18.03.1-ce, build 9ee9f40 Apps built using: 2.1-sdk-alpine Apps deployed using: 2.1.1-aspnetcore-runtime-alpine Apps running in docker on CoreOS, full version details below: NAME=“Container Linux by CoreOS” ID=coreos VERSION=1745.7.0 VERSION_ID=1745.7.0 BUILD_ID=2018-06-14-0909
Edit II: kihamo’s fix works. Thank you sir!
We seem to be having this same issue connecting from an Alpine runtime image (from may 30th, the latest AFAIK) to a windows hosted SQL Server (actually to a listener in a high availability cluster if it makes any difference) The sql server version is
[sql_connection_error_stacktrace.txt] (https://github.com/dotnet/corefx/files/2076861/sql_connection_error_stacktrace.txt)
sql_connection_error_csproj.txt
sql_connection_error_dockerfile.txt