日期:2014-05-20  浏览次数:22032 次

求助 could not execute query 异常
系统框架用的是spring.net + nhibernate + iis host wcf
会偶发的出现 could not execute query 异常导致系统崩溃,跟map肯定没关系,因为我执行select getdate()一样挂。
wcf没问题,调用不操作数据库的方法都没事。
而且数据库本身应该也没问题,没有锁出现,也没有很多用户连接。
有时候过几分钟就自己恢复正常,不过多数时候都是杀掉wcf所在的w3wp.exe进程就好。

操作系统是win2008,数据库是sql2008.

实在是不知道从哪里下手,有人能给点建议不?
 

------最佳解决方案--------------------
先试着debug重现问题
推测是调用wcf时的错误,
重点调试wcf,可能出现了调用时不可用
------其他解决方案--------------------
是不是wcf调用sql的代码写法出现问题了,响应时间嫌长,看看有没有多余代码
------其他解决方案--------------------
但是当出现错误的时候wcf方法是可以调用的啊,只要此方法不涉及数据库操作,只有在调用跟数据库相关的方法才会挂。
------其他解决方案--------------------
我看了一下异常和堆栈信息
Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
------其他解决方案--------------------
堆栈
StackTrace
   at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
   at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
   at System.IO.TextWriter.WriteLine(String value)
   at System.IO.TextWriter.SyncTextWriter.WriteLine(String value)
   at NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd)
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
   at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)

会不会是线程安全的问题?
------其他解决方案--------------------
我在数据库操作的方法上加了锁,系统出错的频率好像降低了,但还是有发生,有人能给点一件么~