runtime: System.Net.Security.SslStream throws exception while running EF tests
While running EF tests on Ubuntu against netcoreapp2.1 an exception is thrown
Failed Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorEnsureDeletedTest.Deletes_database(async: False, open: True, ambientTransaction: False)
Error Message:
System.NotSupportedException : The WriteAsync method cannot be called when another write operation is pending.
Stack Trace:
at System.Net.Security.SslStreamInternal.WriteAsyncInternal[TWriteAdapter](TWriteAdapter writeAdapter, ReadOnlyMemory`1 buffer)
at System.Net.Security.SslStreamInternal.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags)
at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose()
at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose()
at System.Data.SqlClient.TdsParser.Disconnect()
at System.Data.SqlClient.SqlInternalConnectionTds.Dispose()
at System.Data.ProviderBase.DbConnectionPool.DestroyObject(DbConnectionInternal obj)
at System.Data.ProviderBase.DbConnectionPool.DeactivateObject(DbConnectionInternal obj)
at System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal obj, Object owningObject)
at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Close()
at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at Microsoft.EntityFrameworkCore.TestUtilities.RelationalTestStore.Dispose() in /home/saurabh/EntityFrameworkCore/src/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestStore.cs:line 41
at Microsoft.EntityFrameworkCore.TestUtilities.SqlServerTestStore.Dispose() in /home/saurabh/EntityFrameworkCore/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs:line 414
at Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorEnsureDeletedTest.<Delete_database_test>d__2.MoveNext() in /home/saurabh/EntityFrameworkCore/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs:line 154
--- End of stack trace from previous location where exception was thrown ---
--- End of stack trace from previous location where exception was thrown ---
--- End of stack trace from previous location where exception was thrown ---
Steps to repro
Clone the EFCore repo https://github.com/aspnet/EntityFrameworkCore
Build the repo from the root using build.sh
Execute the tests in /EntityFrameworkCore/test/EFCore.SqlServer.FunctionalTests Steps:
-
Modify config.json to have a valid connection string (something like) “Data Source=tcp:server,1437;Database=master;Integrated Security=False;Connect Timeout=60;ConnectRetryCount=0;uid=saurabh;pwd=*******;MultipleActiveResultSets=False”
-
Execute test
~/.dotnet/dotnet test --framework netcoreapp2.1 --filter="FullyQualifiedName=Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorEnsureDeletedTest.Deletes_database"
This test passes one out of every 5 times when run for framework netcoreapp2.1 Run the test against netcoreapp2.0 and it passes consistently.
Some in System.Net.Security changed?
Please contact me for the database password via email for quicker setup.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (13 by maintainers)
It’s of course possible there’s an SslStream bug, though at first glance it sounds higher up and that the error is accurate: some code is trying to make a second write while a previous one is still in flight. That’s not supported, nor was it previously. There have been changes to SslStream in 2.1, which could potentially be making a race condition in consuming code more likely to happen.