Repository navigation
Closed
Milestone
Description
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)
Metadata
Metadata
Assignees
Labels
No labels
Activity
AfsanehR-zz commentedon Apr 17, 2018
Hi @hpbieker , just to clarify, what is your environment running your application? are you using Linux containers on windows?
hpbieker commentedon Apr 18, 2018
It is a application compiled using dotnet core 2.0.x on Windows, then I built a alpine image in a docker host running on Ubuntu 16.04 and ran it on the same docker host. So real Linux Docker.
AfsanehR-zz commentedon Apr 24, 2018
Hi @hpbieker . Could you please share the output of
dotnet --infofrom your docker environment?I was not able to run a sample application using either of the runtime-alpine docker images complaining that it requires a dotnet SDK to be installed. Using the published DLL files also gives me error saying
Failed to bind to CoreCLR at '/Test/libcoreclr.so'However, using
2.1.300-preview2-sdk-alpineimage, I am successfully connecting to a SQL Server.While I am investigating on the runtime-alpine docker image, it would be useful to know your environment setting as well. Thanks.
hpbieker commentedon Apr 25, 2018
I see that my project includes a System.Data.SqlClient.dll with fileversion 4.6.25921.2:
And this one (also version 4.6.25921.2):
Which environmental settings would you like me to provide?
hpbieker commentedon May 5, 2018
Where you able to reproduce this?
marcin-jedynski commentedon May 8, 2018
I am facing probably a similar issue, it was tested and proved working with microsoft/dotnet:2.1-sdk and microsoft/aspnetcore:2 image hosted on Alpine Linux.
Today I moved to the new microsoft/dotnet:2.1-sdk-alpine and microsoft/dotnet:2.1-aspnetcore-runtime-alpine. I updated the .csproj file to target netcoreapp2.1 and changed the versions of packages to match the 2.1.0-rc1-final version.
My docker version is Docker version 18.03.0-ce, build 53f9d007af hosted on Alpine Linux 3.7.
The output of trying to run the application looks like this.
Stack trace log:
marcin-jedynski commentedon May 9, 2018
Connection string is ok, double checked that.
I have even tried to use latest packages:
But the outcome was the same.
AfsanehR-zz commentedon May 9, 2018
@hpbieker Thanks for providing the information.
@marcin-jedynski @hpbieker Will update you here soon with the investigation.
AfsanehR-zz commentedon May 11, 2018
Hello @hpbieker @marcin-jedynski
Running a sample connection inside an alpine-docker hosted on ubuntu VM:
Result after performing following commands where I am building the project inside the docker:
My csproj file looks like this:
I ran the same test with the latest image of dotnet:2.1-sdk-alpine and it was successful again:
However, when I tried to run based on the dotnet-docker samples as described here, in which I modified the samples/dotnetapp/dotnetapp/Program.cs file to try and connect to SQL Server, I got this error:
This is the only way I could reproduce the issue. Could you maybe show us the steps in which you are trying to run your application and if it is the same way that I am getting the exception with? Thanks.
marcin-jedynski commentedon May 12, 2018
I should also mention that the same code built using microsoft/dotnet:2.1-sdk and run inside microsoft/dotnet:2.1-aspnetcore-runtime on Linux Manjaro Docker host is running fine with no problems. So this looks like a problem with Alpine images combnied with Alpine Docker host.
Alpine host is running with kernel
4.9.65-1-hardened.My Dockerfile:
Contents of .csproj:
My nuget.config:
Output of dotnet info in alpine-sdk:
Output of version in aspnetcore-runtime-alpine:
marcin-jedynski commentedon May 12, 2018
As a temporary workaround I managed to get it running by switching the runtime stage image from
microsoft/dotnet:2.1-aspnetcore-runtime-alpineto 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-runtimeand contains of modified bypaxctldotnet binary.The same application runs inside it without any problems.
@hpbieker @afsanehr could you test your application running on my image ?
LeoTorok commentedon Jun 6, 2018
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
kihamo commentedon Jun 22, 2018
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-zz commentedon Jun 22, 2018
@LeoTorok I was able to repro using your sample docker file. And the suggestion made by @kihamo worked for me. 🎉 Can you test that as well?
@marcin-jedynski Looking at your Docker file I see you have added
RUN ["apt-get", "install", "paxctl"]Could you please also try @kihamo suggestion? Thanks!
29 remaining items
divega commentedon May 16, 2019
As recently announced in the .NET Blog, focus on new SqlClient features an improvements is moving to the new Microsoft.Data.SqlClient package. For this reason, we are moving this issue to the new repo at https://github.com/dotnet/SqlClient. We will still use https://github.com/dotnet/corefx to track issues on other providers like System.Data.Odbc and System.Data.OleDB, and general ADO.NET and .NET data access issues.
bmarinov commentedon Jun 6, 2019
We just encountered this issue and there seems to be no suitable workaround whatsoever.
I cannot simply run commands on our base images and definitely cannot access the internet on our isolated environments.
This issue has been up for over a year, it might be worth prioritizing it. Currently the official Alpine images are next to worthless.
David-Engel commentedon Jun 6, 2019
@bmarinov The workaround is to ensure the globalization libraries are installed on your OS since SqlClient depends on them for globalization support. You can do this in Docker by adding those libraries to your Docker image on top of the official .NET Core Alpine image:
#81 (comment)
The first change we will make to SqlClient for this issue is to detect the absence of globalization support and throw a better error message indicating it is required and missing. We may later investigate if SqlClient can function safely in Globalization Invariant Mode and what changes may be required for it, but that is not a high priority.
bmarinov commentedon Jun 7, 2019
@David-Engel thanks for the information. The exception being more specific would greatly help in the future, that would be a quick win for these of us trying to narrow down the issue in a timely manner.
On a side note: considering ASPNET Core + EF Core is basically the go-to backend stack, wouldn't it be advisable to change the ASPNET Alpine images to include these globalization libraries? I mean, services should own some data unless we are doing "microservices" by invoking remote functions. In case the increased image size is a problem, is alternative one with a separate tag would be another good option too. I know that's not a question for this repository/project, just looking for some feedback.
The workaround in question, while not optimal, might work for the time being. I can understand why the issue is not high on the list. But this really is a problem for people like me working in a regulated industry. As I mentioned in my previous comment, we cannot simply add a line to our Dockerfile or build a new image manually and push it to our private registry. We are one of these organizations "doing DevOps" while having separate Ops teams. 😅
Anyway, just wanted to shed some light why the workaround might be far from optimal in many cases.
David-Engel commentedon Jun 7, 2019
@bmarinov That's up to the maintainers of the Docker images. We originally filed an issue with them and they said it was on purpose to minimize the container size. The globalization libraries are a very large size/network penalty for applications that don't need it.
The workaround is not really a workaround. It's how they expect you to build your image if your application has a dependency on globalization support. They have documented how to enable globalization mode on top of the base image if you need it.
cheenamalhotra commentedon Aug 28, 2019
Hi @hpbieker @bmarinov
We've updated the driver to throw appropriate exception for globalization invariant mode in GA Release 1.0.19239.1 - Release notes. Closing the issue.
benmccallum commentedon Oct 17, 2019
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.
yukiwongky commentedon Oct 23, 2019
@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.