简体   繁体   English

NHibernate-“ GenericADOException:无法执行查询”

[英]NHibernate - “GenericADOException: could not execute query”

Our production environment that uses NHibernate v3.1.0.4000 suddenly started giving this error when searching with full-text search: 当使用全文搜索进行搜索时,使用NHibernate v3.1.0.4000的生产环境突然开始出现此错误:

[SqlException (0x80131904): Timeout expired. [SqlException(0x80131904):超时已过期。 The timeout period elapsed prior to completion of the operation or the server is not responding.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +404 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1363 System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +59 System.Data.SqlClient.SqlDataReader.get_MetaData() +118 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6388257 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +6389826 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResul 操作完成之前超时的时间,或者服务器没有响应。] System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔值BreakConnection)+404 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()+412系统.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)+1363 System.Data.SqlClient.SqlDataReader.ConsumeMetaData()+59 System.Data.SqlClient.SqlClient.SqlDataReader +118 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,字符串resetOptionsString)+6388257 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,布尔型returnStream,布尔型异步数据+6389389 .SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,布尔值returnStream,字符串方法,DbAsyncResul t result) +538 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +28 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +256 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +19 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +23 NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +845 NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) +580 NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +275 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +205 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParamete t结果)+538 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,布尔型returnStream,String方法)+28 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior行为,String方法)+256 System.Data .SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior行为)+19 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()+23 NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)+845 NHibernate.Loader.Loader。 GetResultSet(IDbCommand st,布尔autoDiscoverTypes,布尔可调用,RowSelection选择,ISessionImplementor会话)+580 NHibernate.Loader.Loader.DoQuery(ISessionImplementor会话,QueryParameters queryParameters,布尔returnProxies)+275 NHibernate.Loader.Loader.DoQueryAndInitializeN( queryParameters,布尔型returnProxies)+205 NHibernate.Loader.Loader.DoList(ISessionImplementor会话,QueryParameters queryParamete rs) +195 rs)+195

[GenericADOException: could not execute query [ SELECT count(distinct this_.IdDocument) as y0_ FROM Document.Document this_ inner join Document.DocumentCopy documentc1_ on this_.IdDocument=documentc1_.IdDocument WHERE ((@p0 = @p1 and contains(this_.Title, @p2)) and this_.IsDeleted = @p3) and (((@p4 = @p5 and documentc1_.CreationDate >= @p6) and documentc1_.CreationDate <= @p7) and (documentc1_.IdOwnedByGroup = @p8 or documentc1_.IdCreatedByGroup = @p9)) ] Positional parameters: #0>0 #1>0 #2>"ýÿýÿýÿýÿýÿýÿýÿýÿ*" #3>False #4>0 #5>0 #6>12/5/2015 12:00:00 ýÿýÿ #7>12/5/2016 11:59:00 ýÿýÿ #8>1 #9>1 [SQL: SELECT count(distinct this_.IdDocument) as y0_ FROM Document.Document this_ inner join Document.DocumentCopy documentc1_ on this_.IdDocument=documentc1_.IdDocument WHERE ((@p0 = @p1 and contains(this_.Title, @p2)) and this_.IsDeleted = @p3) and (((@p4 = @p5 and documentc1_.CreationDate >= @p6) and documentc1_.CreationDate <= @p7) and (documentc1_.IdOwnedByGroup = @p8 o [GenericADOException:无法执行查询[SELECT count(distinct this_.IdDocument)as y0_ FROM Document.Document this_内部连接Document.DocumentCopy在this_.IdDocument = documentc1_.IdDocument WHERE上((@@ p0 = @ p1并包含(this_。标题@ p2))和this_.IsDeleted = @ p3)和((((@ p4 = @ p5和documentc1_.CreationDate> = @ p6)和documentc1_.CreationDate <= @ p7)和(documentc1_.IdOwnedByGroup = @ p8或documentc1_.IdCreatedByGroup = @ p9)))位置参数:#0> 0#1> 0#2>“ýÿýÿýÿýÿýÿýÿýÿýÿ*”#3> False#4> 0#5> 0#6> 12/5/2015 12:00 :00下午#7> 12/5/2016 11:59:00下午#8> 1#9> 1 [SQL:SELECT count(distingt this_.IdDocument)as y0_ FROM Document.Document this_ inner join Document.DocumentCopy documentc1_ on this_.IdDocument = documentc1_.IdDocument在哪里((@ p0 = @ p1并包含(this_.Title,@ p2))和this_.IsDeleted = @ p3)和((((@ p4 = @ p5和documentc1_.CreationDate> = @ p6)和documentc1_.CreationDate <= @ p7)和(documentc1_.IdOwnedByGroup = @ p8 o r documentc1_.IdCreatedByGroup = @p9))]] NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +637 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +23 NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) +60 NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +1025 NHibernate.Impl.CriteriaImpl.List(IList results) +63 NHibernate.Impl.CriteriaImpl.UniqueResult() +57 Domain.Repositories.DocumentRepository.Domain.Abstract.IDocumentRepository.GetAll(Criteria 1 criteria, Int32& count, Dictionary 2 openFieldCriteria) +272 ServicesImplementation.DocumentService.GetDocuments(Criteria 1 criteria, Int32& count, String metadataSearchTerm) +510 Docman.Models.List.ListModel.GetDocuments(Int32& count) +102 ASP._Page_Views_List_Index_cshtml.Execute() in d:\\wwwroot\\inetpub\\docman\\Views\\List\\Index.cshtml:27 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104 System.Web.WebPages.StartPage.ExecutePageHierarchy() +143 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +157 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func r documentc1_.IdCreatedByGroup = @ p9))]] NHibernate.Loader.Loader.DoList(ISessionImplementor会话,QueryParameters queryParameters)+637 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor会话,QueryParameters queryParameters)+23 NHibernate.LoaderCerteria .List(ISessionImplementor会话)+60 NHibernate.Impl.SessionImpl.List(CriteriaImpl标准,IList结果)+1025 NHibernate.Impl.CriteriaImpl.List(IList结果)+63 NHibernate.Impl.CriteriaImpl.UniqueResult()+57域。 Repositories.DocumentRepository.Domain.Abstract.IDocumentRepository.GetAll(条件1 criteria, Int32& count, Dictionary 2 openFieldCriteria)+272 ServicesImplementation.DocumentService.GetDocuments(条件1 criteria, Int32& count, String metadataSearchTerm) +510 Docman.Models.List.ListModel.GetDocuments(Int32& count) +102 ASP._Page_Views_List_Index_cshtml.Execute() in d:\\wwwroot\\inetpub\\docman\\Views\\List\\Index.cshtml:27 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104 System.Web.WebPages.StartPage.ExecutePageHierarchy() +143 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +157 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func 1 criteria, Int32& count, String metadataSearchTerm) +510 Docman.Models.List.ListModel.GetDocuments(Int32& count) +102 ASP._Page_Views_List_Index_cshtml.Execute() in d:\\wwwroot\\inetpub\\docman\\Views\\List\\Index.cshtml:27 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104 System.Web.WebPages.StartPage.ExecutePageHierarchy() +143 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +157 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func 1 continuation) +826372 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +827248 System.Web.Mvc.Controller.ExecuteCore() +159 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335 System.Web.Mvc.<>c__DisplayClassb.b__5() +62 System. 1 criteria, Int32& count, String metadataSearchTerm) +510 Docman.Models.List.ListModel.GetDocuments(Int32& count) +102 ASP._Page_Views_List_Index_cshtml.Execute() in d:\\wwwroot\\inetpub\\docman\\Views\\List\\Index.cshtml:27 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104 System.Web.WebPages.StartPage.ExecutePageHierarchy() +143 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +157 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func 1延续)+826372 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext,IList`1过滤器,ActionResult actionResult)+265 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext,字符串actionName)+827248 System.Web.Mvc。 Controller.ExecuteCore()+159 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)+335 System.Web.Mvc。<> c__DisplayClassb.b__5()+62系统。 Web.Mvc.Async.<>c__DisplayClass1.b__0() +20 System.Web.Mvc.<>c__DisplayClasse.b__d() +54 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375 Web.Mvc.Async。<> c__DisplayClass1.b__0()+20 System.Web.Mvc。<> c__DisplayClasse.b__d()+54 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+469系统.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值并已同步完成)+375

I have tried the above listed query on SSMS and it seemed running fine and fast. 我已经在SSMS上尝试了上面列出的查询,它似乎运行良好且快速。

A similar error is mentioned here: Nhibernate FieldNameLookup throws IndexOutOfRangeException , although my error message does not contain any IndexOutOfRangeException in it. 这里提到了类似的错误: Nhibernate FieldNameLookup抛出IndexOutOfRangeException ,尽管我的错误消息中没有包含任何IndexOutOfRangeException

Can anyone tell me what could be the cause of this? 谁能告诉我这可能是什么原因?

UPDATE: 更新:

More info : 更多信息 :

We are using projections. 我们正在使用投影。

According to the error log, the error originates from some query that only returns a count and not many rows with many fields. 根据错误日志,该错误源自某些查询,该查询仅返回一个计数,并且不包含具有许多字段的行。

As I have said before, the same query (listed in the error log) runs fast and with no issues when I run it from SSMS. 就像我之前说过的一样,从SSMS运行相同的查询(在错误日志中列出)运行很快,没有任何问题。 Yet, all queries made from the app that execute this SQL query seem to fail with the above error. 但是,从应用程序执行该SQL查询的所有查询似乎都因上述错误而失败。

The code might not be clear to you since we use a custom wrapper for NH. 由于我们为NH使用了自定义包装,因此代码可能对您不清楚。

I think I am wrong on the order of exceptions and first the timeout happens and then the ADO.net reports the other error. 我认为我在异常顺序上是错误的,首先发生超时,然后ADO.net报告另一个错误。 So, I guess it is a timeout after all... 所以,我想毕竟是一个超时...

UPDATE 2: 更新2:

After some extra research, it seems this is related to this issue and the query is indeed timing out, just not from SSMS: 经过一些额外的研究,似乎这与此问题有关,并且查询确实超时了,而并非来自SSMS:

Query times out when executed from web, but super-fast when executed from SSMS 从Web执行时查询超时,但从SSMS执行时超快

That turned out to be a timeout which could not be reproduced from SSMS because there it was using a different value for ARITHABORT (between my app session and the SSMS session). 事实证明这是一个超时,无法从SSMS中重现,因为它为ARITHABORT使用了一个不同的值(在我的应用程序会话和SSMS会话之间)。

Once I had set the default value for it to ON / 1 for the DB, everything was fixed: 将数据库的默认值设置为ON / 1 ,所有问题均已修复:

USE [master];
GO
ALTER DATABASE [{database_name}] SET ARITHABORT ON WITH NO_WAIT;
GO

See here: https://dba.stackexchange.com/a/95090/71232 看到这里: https : //dba.stackexchange.com/a/95090/71232

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM