SqlClient电话造成的"螺纹是被中止在SNINativeMethodWrapper.SNIPacketGetConnection(因此分组)"

StackOverflow https://stackoverflow.com/questions/424531

我会很感激的任何建议,不管如何简单或复杂,以帮助我得到这个孤立的问题和解决。

我有一位的代码生成的小报告的文件。每个文件在收集、存储proc是执行以获得的数据通过XML读者(它是一个相当大的结果设定)。当我创造了这一切,加紧通过它,一切都很好。文件产生的,任何错误。

这个图书馆是通过远程处理的,而托管通过IIS。当我的部署编制的图书馆,并呼叫它,它能够产生一些报告,但后来引发线程中止例外。如果我附上的调试器asp的工作进程,并逐步通过代码,我已经没有问题。

看到如此失败是相当一致的,我看了相似之处并发现,失败的情况发生在不同的报告,但是似乎发生在大约同一时间顺序点。

这导致我认为这是一个超时设置调试器是首要的,我没有一些粗略时间的整个过程(不是单一件失败的代码)和似乎无法在刚后,大约200秒钟。网络。config executionTimeout设置600分钟(大量足够高的).还有其他部件这个服务器的应用程序,需要COM+交易(2分钟超时),但这不是他们中的一个。我在失去什么超时它可能是打击(在大约200二的标记)。

SQL连接的超时留在默认(连接打开了成功),该命令超时为300秒(只需要12至15到执行的命令)。

  • 是否有任何其他时间超时,我可能是丢失?

我跑SQL分析器,这显示,结果是返回正确地(所有声明和RPC完成了-没有错误)。执行代码通过短程提供了完美的结果。

使用反射镜,我钻到SNINativeMethodWrapper,其包装的非托管码我不能看到什么其试图实际上做的。我只能假设(或许错误地)的代码已收到的TDS从SQL服务器和包装试图获得连接的与分组相关的,它不能。

  • 任何人都不会知道这是什么包装是应该做的?
  • 是否有任何办法追踪和调试这个代码中找出是什么造成的失败?

我试图用不同的方法(ExecScalar,起到桥梁作用),但它们都使用ExecuteReader内部。

我试图禁止池连接并迫使客户使用同一分组的大小作为服务器。

  • 没有任何人有任何想法是什么原因导致的,或者什么我可以做隔离和尝试纠正这个问题?

这是调用代码在哪里唯一的例外是产生。

Private Function GetDataAsXmlDoc(ByVal cmd As SqlClient.SqlCommand) As XmlDocument

    Dim _xmlDoc As XmlDocument

    Using _connection As New SqlClient.SqlConnection(GetConnectionString())

        Logging.DebugEvent.Raise(Me.GetType.Namespace, Reflection.MethodBase.GetCurrentMethod().Name, _
                                 "No cached data found or used. Getting data for report from the database using SQL connection.")

        Dim _xmlReader As XmlReader
        'DataAdapter,ExecuteScalar, ExecuteXmlReader all use ExecuteReader internally and suffer the same problem.'
        'If you dont believe me, reflect it or look at one of the blowed up stack traces. '

        '_connection.ConnectionString += ";Pooling=false;"' 'This has no effect on the ThreadAbort.'
        cmd.Connection = _connection
        cmd.CommandTimeout = 300
        _connection.Open()

        Logging.DebugEvent.Log(String.Format("Connection opened, using packet size of {0}.", _connection.PacketSize))

        _xmlReader = cmd.ExecuteXmlReader() 'Thread aborts in here'

        Logging.DebugEvent.Raise(Me.GetType.Namespace, Reflection.MethodBase.GetCurrentMethod().Name, _
                                 "Report data recieved from database")

        _xmlDoc = New XmlDocument()
        _xmlDoc.Load(_xmlReader)

        _xmlReader.Close()

    End Using

  Return _xmlDoc

End Function

Exception String - System.Threading.ThreadAbortException: Thread was being aborted.
   at SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr packet)
   at System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket(IntPtr packet, UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
   at System.Data.SqlClient.TdsParserStateObject.ReadByte()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteXmlReader()...
有帮助吗?

解决方案

我相信我已经解决了该问题。违规行代码在上面的例子是声明...

 Logging.DebugEvent.Raise(Me.GetType.Namespace, Reflection.MethodBase.GetCurrentMethod().Name, _
                                 "Report data recieved from database")

这是一个叫到一块应用(MS企业图书馆)用于记录事件,以平的文件(在这种情况下)或事件的记录。

这一次,在两者之间的ExecuteXMLReader()以及实际使用情况的读者在XML文件,有时无法严厉,导致整个线程,以中止。我移动线路以后 _xmlReader.Close() 和它采取了照顾的问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top