SQLDependency 在 SQL Server 重新启动时挂起
我有注册多个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论