You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microsoft.Data.SqlClient.SqlDependency.Stop(string) in Microsoft.Data.SqlClient 1.1.2 does not remove the stored procedure created.
Steps to reproduce:
Use Command Prompt (cmd) to start a SQL Server in Docker:
docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=GitHub4567Issue$%^&Password" -p 4567:1433 mcr.microsoft.com/mssql/server:2017-latest
Start Microsoft SSMS and connect to the SQL Server.
Server type: Database Engine
Server name: localhost,4567
Authentication: SQL Server Authentication
Login: sa
Password: GitHub4567Issue$%^&Password
Open a New Query tab, and run the following SQL to create a database ready for SqlDependency:
CREATEDATABASEtestGitHubIssue;
ALTERDATABASE testGitHubIssue SET ENABLE_BROKER;
In Object Explorer, go to localhost,4567 > Databases > testGitHubIssue > Programmability > Stored Procedures. Verify that there're no user stored procedures yet.
Start Visual Studio, and choose Create a new project > C# Console App (.NET Core) to create a new project.
In the project, choose Project > Manage NuGet Packages, find the Microsoft.Data.SqlClient package, and install the version 1.1.2.
then set a breakpoint on the line with SqlDependency.Stop.
Run the console program in Visual Studio, and wait until it stops at the breakpoint. Now in SSMS, do a refresh and verify that a new stored procedure is created with a name similar to SqlQueryNotificationStoredProcedure-5e2958e2-f0e5-46cb-9f6e-9db02488c545.
In Visual Studio, click Continue to resume the program. Now in SSMS, do a refresh and check the stored procedures.
Expected behavior
The stored procedure should be removed by SqlDependency.Stop().
Actual behavior
The stored procedure remains. Note that this does not happen to Microsoft.Data.SqlClient 1.1.1.
Version info
Microsoft.Data.SqlClient version: 1.1.2
.NET target: .NET Core 3.1
SQL Server version: Microsoft SQL Server 2017 (RTM-CU20) (KB4541283) - 14.0.3294.2 (X64)
Operating system: Microsoft Windows 10 Pro Version 1909 (OS Build 18363.778)
Visual Studio: Microsoft Visual Studio Community 2019 Version 16.5.4
Additional info
Rider says an exception like this is caught and swallowed in SqlDependencyProcessDispatcher.cs line 834.
Microsoft.Data.SqlClient.SqlException (0x80131904): The transaction operation cannot be performed because there are pending requests working on this transaction.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at SqlDependencyProcessDispatcher.SqlConnectionContainer.TearDownAndDispose()
ClientConnectionId:47b2dbcb-b256-416e-8b78-a403d8a5d81c
Error Number:3981,State:1,Class:16
The text was updated successfully, but these errors were encountered:
Describe the bug
Microsoft.Data.SqlClient.SqlDependency.Stop(string)
inMicrosoft.Data.SqlClient
1.1.2 does not remove the stored procedure created.Steps to reproduce:
Use Command Prompt (
cmd
) to start a SQL Server in Docker:Start Microsoft SSMS and connect to the SQL Server.
Open a New Query tab, and run the following SQL to create a database ready for
SqlDependency
:In Object Explorer, go to
localhost,4567
> Databases >testGitHubIssue
> Programmability > Stored Procedures. Verify that there're no user stored procedures yet.Start Visual Studio, and choose Create a new project > C# Console App (.NET Core) to create a new project.
In the project, choose Project > Manage NuGet Packages, find the Microsoft.Data.SqlClient package, and install the version 1.1.2.
In
Program.cs
, type this:then set a breakpoint on the line with
SqlDependency.Stop
.Run the console program in Visual Studio, and wait until it stops at the breakpoint. Now in SSMS, do a refresh and verify that a new stored procedure is created with a name similar to
SqlQueryNotificationStoredProcedure-5e2958e2-f0e5-46cb-9f6e-9db02488c545
.In Visual Studio, click Continue to resume the program. Now in SSMS, do a refresh and check the stored procedures.
Expected behavior
The stored procedure should be removed by
SqlDependency.Stop()
.Actual behavior
The stored procedure remains. Note that this does not happen to
Microsoft.Data.SqlClient
1.1.1.Version info
Microsoft.Data.SqlClient version: 1.1.2
.NET target: .NET Core 3.1
SQL Server version: Microsoft SQL Server 2017 (RTM-CU20) (KB4541283) - 14.0.3294.2 (X64)
Operating system: Microsoft Windows 10 Pro Version 1909 (OS Build 18363.778)
Visual Studio: Microsoft Visual Studio Community 2019 Version 16.5.4
Additional info
Rider says an exception like this is caught and swallowed in
SqlDependencyProcessDispatcher.cs
line 834.The text was updated successfully, but these errors were encountered: