Oracle ManagedDataAccess 4.122.18.3 为某些 SQL 查询获取 ORA-12537

Oracle ManagedDataAccess 4.122.18.3 gets ORA-12537 for some SQL-queries

我们已经成功使用Oracle ManagedDataAccess 4.122.1.0 很长时间了。 升级到 Oracle ManagedDataAccess 4.122.18.3 后,某些 SQL 查询工作正常,但某些 SQL 查询开始不断导致 ORA-12537 错误:

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12537: Network Session: End of file ---> OracleInternal.Network.NetworkException (0x000030F9): ORA-12537: Network Session: End of file
   at OracleInternal.Network.ReaderStream.Read(OraBuf OB)
   at OracleInternal.TTC.OraBufReader.GetDataFromNetwork()
   at OracleInternal.TTC.OraBufReader.Read(Boolean bIgnoreData)
   at OracleInternal.TTC.TTCExecuteSql.ReceiveExecuteResponse(Accessor[]& defineAccessors, Accessor[] bindAccessors, Boolean bHasReturningParams, SQLMetaData& sqlMetaData, SqlStatementType statementType, Int64 noOfRowsFetchedLastTime, Int32 noOfRowsToFetch, Int32& noOfRowsFetched, Int64& queryId, Int32 longFetchSize, Int64 initialLOBFetchSize, Int64[] scnFromExecution, Boolean bAllInputBinds, Int32 arrayBindCount, DataUnmarshaller& dataUnmarshaller, MarshalBindParameterValueHelper& marshalBindParamsHelper, Int64[]& rowsAffectedByArrayBind, Boolean bDefineDone, Boolean& bMoreThanOneRowAffectedByDmlWithRetClause, List`1& implicitRSList, Boolean bLOBArrayFetchRequired)
   at Oracle.ManagedDataAccess.Client.OracleException.HandleError(OracleTraceLevel level, OracleTraceTag tag, OracleTraceClassName className, OracleTraceFuncName funcName, Exception ex, OracleLogicalTransaction oracleLogicalTransaction)
   at OracleInternal.TTC.TTCExecuteSql.ReceiveExecuteResponse(Accessor[]& defineAccessors, Accessor[] bindAccessors, Boolean bHasReturningParams, SQLMetaData& sqlMetaData, SqlStatementType statementType, Int64 noOfRowsFetchedLastTime, Int32 noOfRowsToFetch, Int32& noOfRowsFetched, Int64& queryId, Int32 longFetchSize, Int64 initialLOBFetchSize, Int64[] scnFromExecution, Boolean bAllInputBinds, Int32 arrayBindCount, DataUnmarshaller& dataUnmarshaller, MarshalBindParameterValueHelper& marshalBindParamsHelper, Int64[]& rowsAffectedByArrayBind, Boolean bDefineDone, Boolean& bMoreThanOneRowAffectedByDmlWithRetClause, List`1& implicitRSList, Boolean bLOBArrayFetchRequired)
   at OracleInternal.ServiceObjects.OracleDataReaderImpl.FetchMoreRows(Int32 noOfRowsToFetch, Boolean fillReader, Boolean returnPSTypes)
   at Oracle.ManagedDataAccess.Client.OracleDataReader.Read()
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies, IResultTransformer forcedResultTransformer)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies, IResultTransformer forcedResultTransformer)
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters, IResultTransformer forcedResultTransformer)

此类查询的示例如下(由 NHibernate 生成):

select
   ID1_87_0_,
   ...
from
   (
      select
         NODEENTITY0_.ID as ID1_87_0_,
         ...
      from
         NODES NODEENTITY0_ 
         left outer join DIVISIONS DIVISIONEN1_ 
            on NODEENTITY0_.IDDIV = DIVISIONEN1_.ID 
         left outer join CONTRACTS CONTRACTEN2_ 
            on NODEENTITY0_.IDCONTRACT = CONTRACTEN2_.ID 
         left outer join ABONENTS ABONENTENT3_ 
            on CONTRACTEN2_.IDABONENT = ABONENTENT3_.ID 
         left outer join WATERWAYS WATERWAYEN4_ 
            on CONTRACTEN2_.IDWATERWAY = WATERWAYEN4_.ID 
         left outer join WARRANTY WARRANTYEN5_ 
            on NODEENTITY0_.IDWARRANTYLAST = WARRANTYEN5_.ID 
            and NODEENTITY0_.IDDIV = WARRANTYEN5_.IDDIVISION 
         left outer join SERVICECENTER SERVICECEN6_ 
            on WARRANTYEN5_.ID_SERVICECENTER = SERVICECEN6_.ID 
         left outer join PUS PUENTITY7_ 
            on NODEENTITY0_.IDPULAST = PUENTITY7_.ID 
         left outer join TPPUS TPPUENTITY8_ 
            on PUENTITY7_.IDTPPU = TPPUENTITY8_.ID 
      order by
         NODEENTITY0_.ID asc 
   )
where
   ROWNUM <= :P0;

完全相同的 SQL- 查询正在使用 Oracle ManagedDataAccess 4.122.1.0 执行,没有任何错误。

我们对 Oracle ManagedDataAccess 4.122.18.3 做错了什么?

技术细节:

检查 System Requirements 是否有 ODP.NET 托管驱动程序,版本 18

Oracle Data Provider for .NET, Managed Driver requires the following:

  • Same Windows operating system support as ODP.NET, Unmanaged Driver.

  • ODP.NET, Managed Driver is built with AnyCPU. It runs on either 32-bit or 64-bit (x64) Windows and on either 32-bit or 64-bit (x64) .NET Framework.

  • Microsoft .NET Framework 4.5.2, 4.6.x, or 4.7.x.

  • Access to Oracle Database 11g Release 2 or later

如您所见,ODP.NET 托管驱动程序版本 18 不再支持 Oracle 数据库 10.2。升级您的数据库(版本 10.2 大约有 15 年历史)

对于 ODP.NET 托管驱动程序,版本 12.2 System Requirements 说:

  • Access to Oracle Database 10g Release 2 or later

我从 nuget for Oracle Database 10g 引用 Oracle.DataAccess 时解决了我的问题。