100%CPU,卡在CreateDelegate和CerHashtable`2.get_Item上

时间:2015-09-17 23:17:58

标签: c# asp.net vb.net linq windbg

我有一个.NET 3.5网站,偶尔会挂起并激活到100%的CPU。通过WinDbg运行转储显示我的大约一半的线程位于

System.Reflection.CerHashtable`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].get_Item(System.__Canon)

而另一半正坐在

System.Reflection.Emit.DynamicMethod.CreateDelegate(System.Type)

它们都处于LINQ-to-SQL查询的中间。有谁知道这里会发生什么?数据库似乎仍然保持响应,至少在SSMS问题发生时仍在响应。

如果有人需要更多信息,请与我们联系。

修改

有22个主题。 (当我说一半时我正在推广)这是!threads的输出

ThreadCount: 23
UnstartedThread: 0
BackgroundThread: 22
PendingThread: 0
DeadThread: 1
Hosted Runtime: no
                                              PreEmptive                                                Lock
       ID OSID        ThreadOBJ     State   GC     GC Alloc Context                  Domain           Count APT Exception
   7    1 19a0 00000000022c7710      8220 Enabled  0000000000000000:0000000000000000 00000000022a2940     0 Ukn
  27    2 1fa0 0000000005591f90      b220 Enabled  00000001a0425058:00000001a04266c0 00000000022a2940     0 MTA (Finalizer)
  29    3 4824 0000000006550450   380b220 Enabled  000000012213cf18:000000012213dec0 00000000067500a0     1 MTA (Threadpool Worker)
  30    4 40c8 00000000061378c0   380b220 Enabled  00000001c1f84c38:00000001c1f860f0 00000000067500a0     1 MTA (Threadpool Worker)
  31    5 2a54 0000000006138770   180b220 Disabled 0000000101e3c858:0000000101e3db00 00000000067500a0     2 MTA (Threadpool Worker)
  32    6 1984 000000000613c940   180b220 Enabled  0000000000000000:0000000000000000 00000000067500a0     0 MTA (Threadpool Worker) System.ObjectDisposedException (000000017fffe458)
  33    7 18d8 000000000613eb80   380b220 Enabled  00000001820c3a30:00000001820c3c90 00000000067500a0     1 MTA (Threadpool Worker)
  34    8 31f4 0000000006141d10   380b220 Enabled  0000000122147048:0000000122147ec0 00000000067500a0     1 MTA (Threadpool Worker)
  35    9 5fe4 00000000061427c0   180b220 Enabled  00000001e1ffbdc8:00000001e1ffc190 00000000067500a0     2 MTA (Threadpool Worker)
  36    a 3768 0000000006143270   180b220 Enabled  00000001e200add0:00000001e200c190 00000000067500a0     1 MTA (Threadpool Worker)
  37    b 1820 000000000670fa10    80a220 Enabled  0000000000000000:0000000000000000 00000000022a2940     0 MTA (Threadpool Completion Port)
  38    c 1220 000000000673e160      1220 Enabled  0000000000000000:0000000000000000 00000000022a2940     0 Ukn
  39    d 507c 0000000008c1f9b0   180b220 Enabled  0000000101e392d0:0000000101e39b00 00000000067500a0     2 MTA (Threadpool Worker)
  14    e 651c 000000000a507000   880a220 Enabled  0000000000000000:0000000000000000 00000000022a2940     0 MTA (Threadpool Completion Port)
  40    f 14a0 000000000ab0a850   380b220 Enabled  00000001a15886c0:00000001a158a638 00000000067500a0     1 MTA (Threadpool Worker)
XXXX   10    0 000000000bd7c7b0      9820 Enabled  0000000000000000:0000000000000000 00000000022a2940     0 MTA
  42   11 48d8 000000000c00c120   380b220 Enabled  0000000000000000:0000000000000000 00000000067500a0     0 MTA (Threadpool Worker)
   3   12 6180 000000000c00c6f0       220 Enabled  0000000000000000:0000000000000000 00000000022a2940     0 Ukn
  43   13 3798 000000000c00d290   180b220 Enabled  00000001420f9730:00000001420f9828 00000000067500a0     2 MTA (Threadpool Worker)
  45   14 1be8 000000001184f150   180b220 Enabled  00000001c1f880e0:00000001c1f880f0 00000000067500a0     2 MTA (Threadpool Worker)
  48   15 13ec 000000001184f720   200b220 Enabled  0000000000000000:0000000000000000 00000000067500a0     1 MTA
  49   17 3bac 00000000198f1b20   180b220 Enabled  0000000182059020:0000000182059c90 00000000067500a0     2 MTA (Threadpool Worker)
  50   16 4670 00000000197b6b00   380b220 Enabled  0000000162040fd0:0000000162042658 00000000067500a0     1 MTA (Threadpool Worker)

这是!EEStack的长期结果(贴在pastebin上,因为它不适合这篇文章)

http://pastebin.com/qcF4jX1g

我正在使用SQL 2005标准

修改

结果是!syncblk,它显示“CerHashtable”作为所有者,虽然CerHashtable上的所有线程似乎都在等待锁定?

Index         SyncBlock MonitorHeld Recursion Owning Thread Info          SyncBlock Owner
  148 000000000e4ec1f8           12         0 0000000000000000     none    000000017fe48560 System.Reflection.CerHashtable`2[[System.Reflection.RuntimeMethodInfo, mscorlib],[System.Reflection.RuntimeMethodInfo, mscorlib]]
        Waiting threads:*** WARNING: Unable to verify checksum for NewRelic.Profiler.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for NewRelic.Profiler.dll - 
 29 30 33 34 40 50
-----------------------------
Total           252
CCW             3
RCW             5
ComClassFactory 0
Free            81

1 个答案:

答案 0 :(得分:0)

  

Linq-To-Sql已被微软停止使用。

他们建议使用实体框架。

由于您的linq代码我们仍然有效,因此不会进行大规模的改革。 您只需要重新创建数据模型。

对于.Net 3.5,您可以使用EF v1。

尝试从http://www.microsoft.com/download/en/details.aspx?id=22下载Microsoft .NET Framework 3.5 Service Pack 1 它应该包括http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework中所述的第一版实体框架(EFv1)。