Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ODP.net managed driver throws ORA-12570: Network Session: Unexpected packet read error

In one of our products we retrieve data from the Oracle database using stored procedures using the ODP.net managed driver.

Every now and then (roughly every 1000 queries) we get the following exception:

(ORA-12570: Network Session: Unexpected packet read error)
---> Oracle.ManagedDataAccess.Client.OracleException: ORA-12570: Network Session: Unexpected packet read error
---> OracleInternal.Network.NetworkException: ORA-12570: Network Session: Unexpected packet read error
---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: size
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
   at OracleInternal.Network.ReaderStream.ReadIt(OraBuf OB, Int32 len)
   --- End of inner exception stack trace ---
   at OracleInternal.Network.ReaderStream.ReadIt(OraBuf OB, Int32 len)
   at OracleInternal.Network.ReaderStream.WaitForReset()
   at OracleInternal.Network.OracleCommunication.Reset()
   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, Int32 initialLOBFetchSize, Int64[] scnFromExecution, Boolean& bAllPureInputBinds, DataUnmarshaller& dataUnmarshaller, MarshalBindParameterValueHelper& marshalBindParamsHelper, Boolean bDefineDone, Boolean& bMoreThanOneRowAffectedByDmlWithRetClause)
   --- End of inner exception stack trace ---
   at Oracle.ManagedDataAccess.Client.OracleException.HandleError(OracleTraceLevel level, OracleTraceTag tag, Exception ex)
   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, Int32 initialLOBFetchSize, Int64[] scnFromExecution, Boolean& bAllPureInputBinds, DataUnmarshaller& dataUnmarshaller, MarshalBindParameterValueHelper& marshalBindParamsHelper, Boolean bDefineDone, Boolean& bMoreThanOneRowAffectedByDmlWithRetClause)
   at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, Int32 longFetchSize, Int32 lobPrefetchSize, OracleDependencyImpl orclDependencyImpl, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Boolean isFromEF)
   at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()

It seems like ODP.net is calling System.Net.Sockets.Socket.Receive with an invalid size parameter (<=0 or greater than the length of buffer minus the value of the offset parameter).

The exception cannot be reproduced manually and is never raised while executing different procedures with different parameters (ie it's random).

Configuration: ODP.net managed driver version: 4.121.1.0 .net framework 4.5 Oracle server version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 (Linux)

Has anyone already experienced this issue? Are there any fixes available?

Thanks in advance!

like image 622
vc 74 Avatar asked Nov 25 '14 08:11

vc 74


People also ask

What is error code Ora 12570?

ORA-12570: Network Session: Unexpected packet read error when attempting to connect via the 12.1.0.2 Managed ODP.NET provider. To view full details, sign in with your My Oracle Support account. Don't have a My Oracle Support account? Click to get started!

Why can't I connect with managed ODP?

If the DB server is requiring checksumming, then you can't connect with managed ODP.NET at this time. Managed ODP.NET does not support checksumming yet, but it will. Another possibility is that the DB is requiring encryption, but you don't have ODP.NET configured to accept the encryption the server is requesting.

Is random ora-12570 error a pooling problem?

After reading through a similar question at ODP.NET Oracle.ManagedDataAcess random ORA-12570 errors, it seems like it's actually a pooling problem.

How do I fix ora-12571?

Ora-12571 might be slightly different. But still since you've identified that the issue is the same in that it's long established pool connections I'll keep going. Set min pool size = 0 in the connection string. This generally fixes things for me. It allows the entire pool to be closed out when the app is idle.


2 Answers

After opening a ticket with the Oracle support, they sent an unofficial updated version of the managed ODP.net library which seems to fix the issue.

Hopefully the fix should be part of the next ODAC release (the latest available today is from Oct 2015).

If you see this error in your application, it's probably due to the same bug in the managed ODP.net library, not the way you use it.

Another thing to consider is if something in the network infrastructure could interrupt idle tcp/ip connections during the execution of long requests as described in this SO answer.

like image 187
vc 74 Avatar answered Oct 19 '22 10:10

vc 74


After reading through a similar question at ODP.NET Oracle.ManagedDataAcess random ORA-12570 errors, it seems like it's actually a pooling problem. Apparently the answer is to either set Pooling=false in the Connection String, or to find out just how many threads can be opened and how long the connection can be open before it becomes too much for Oracle to handle. This was the answer the author of that question posted:

To find the best configuration with pooling enabled I created a test application to start 50 threads (each one doing 1 test each 50ms), and decreased the default pool values until the error stoped. This way I was able to get an optimal configuration, stable, without any errors.

Obviously it does not applies to every server, but this is my final connection string configuration:

Pooling=true;Min Pool Size=1;Connection Lifetime=180;Max Pool Size=50;Incr Pool Size=5

like image 35
vapcguy Avatar answered Oct 19 '22 12:10

vapcguy