SQLDependency 在 SQL Server 重新启动时挂起

发布于 2024-12-09 17:39:20 字数 3201 浏览 1 评论 0原文

我有注册多个 SQLDependency 的应用程序;当数据库中发生更改时会触发事件。

在正常情况下一切正常,但如果我们多次重新启动 SQL Server,则注册通知的新请求就会挂起。

进行转储并通过分析发现 SQL 线程具有下面提到的堆栈。有谁知道这个线程在做什么?

System.Data.SqlClient.SqlInternalConnection.OnError(System.Data.SqlClient.SqlException, Boolean)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
System.Data.SqlClient.TdsParser.Run(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject)
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean)
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(System.Data.SqlClient.ServerInfo, System.String, Boolean, System.Data.SqlClient.SqlConnection, System.Data.SqlClient.SqlConnectionString, System.Data.ProviderBase.TimeoutTimer)
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(System.Data.SqlClient.SqlConnection, System.Data.ProviderBase.TimeoutTimer, System.Data.SqlClient.SqlConnectionString, System.String, Boolean)
System.Data.SqlClient.SqlInternalConnectionTds..ctor(System.Data.ProviderBase.DbConnectionPoolIdentity, System.Data.SqlClient.SqlConnectionString, System.Object, System.String, System.Data.SqlClient.SqlConnection, Boolean)
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection)
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionPoolGroup)
System.Data.ProviderBase.DbConnectionFactory.GetConnection(System.Data.Common.DbConnection)
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory)
System.Data.SqlClient.SqlConnection.Open()
SqlDependencyProcessDispatcher+SqlConnectionContainer.Restart(System.Object)
SqlDependencyProcessDispatcher+SqlConnectionContainer.AsyncResultCallback(System.IAsyncResult)
System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, Boolean)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
System.Data.SqlClient.SqlCommand.InternalEndExecuteReader(System.IAsyncResult, System.String)
System.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)
SqlDependencyProcessDispatcher+SqlConnectionContainer.AsyncResultCallback(System.IAsyncResult)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
System.Data.Common.DbAsyncResult.ExecuteCallback(System.Object)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
System.Threading.ThreadPoolWorkQueue.Dispatch()
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

I have application which registers multiple SQLDependencies; and events are fired when change occur in DB.

Everything works fine in normal circumstance but if we restart SQL Server multiple times then the new request to register notification gets hangs.

Took the dump and from analysis found out that a SQL thread with Undermentioned Stack. Does anyone have any idea what this thread is doing?

System.Data.SqlClient.SqlInternalConnection.OnError(System.Data.SqlClient.SqlException, Boolean)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
System.Data.SqlClient.TdsParser.Run(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject)
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean)
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(System.Data.SqlClient.ServerInfo, System.String, Boolean, System.Data.SqlClient.SqlConnection, System.Data.SqlClient.SqlConnectionString, System.Data.ProviderBase.TimeoutTimer)
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(System.Data.SqlClient.SqlConnection, System.Data.ProviderBase.TimeoutTimer, System.Data.SqlClient.SqlConnectionString, System.String, Boolean)
System.Data.SqlClient.SqlInternalConnectionTds..ctor(System.Data.ProviderBase.DbConnectionPoolIdentity, System.Data.SqlClient.SqlConnectionString, System.Object, System.String, System.Data.SqlClient.SqlConnection, Boolean)
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection)
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionPoolGroup)
System.Data.ProviderBase.DbConnectionFactory.GetConnection(System.Data.Common.DbConnection)
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory)
System.Data.SqlClient.SqlConnection.Open()
SqlDependencyProcessDispatcher+SqlConnectionContainer.Restart(System.Object)
SqlDependencyProcessDispatcher+SqlConnectionContainer.AsyncResultCallback(System.IAsyncResult)
System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, Boolean)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
System.Data.SqlClient.SqlCommand.InternalEndExecuteReader(System.IAsyncResult, System.String)
System.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)
SqlDependencyProcessDispatcher+SqlConnectionContainer.AsyncResultCallback(System.IAsyncResult)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
System.Data.Common.DbAsyncResult.ExecuteCallback(System.Object)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
System.Threading.ThreadPoolWorkQueue.Dispatch()
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文