Toolkit
Toolkit

Reputation: 11119

ShouldRetryOn in DbExecutionStrategy not always works

Mostly it works but sometimes I receive error messages:

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-03135: Connection lost contact

... in C:\xxx\Controllers\XController.cs:line 108

So line 108 is return StatusCode(HttpStatusCode.ExpectationFailed); Weird....


class MyDbConfiguration : DbConfiguration
{
    public MyDbConfiguration()
    {
        SetExecutionStrategy("Oracle.ManagedDataAccess.Client", () => new MyDbExecutionStrategy(3, TimeSpan.FromSeconds(0)));
    }
}

public class MyDbExecutionStrategy : DbExecutionStrategy
{
    public MyDbExecutionStrategy(int maxRetryCount, TimeSpan maxDelay)
        : base(maxRetryCount, maxDelay)        {        }

    protected override bool ShouldRetryOn(Exception ex)
    {
        return true; // for simplicity
    }
}

I had to do another wrapper and catch Oracle errors manually to overcome this. When I debug and simulate DB error the execution consistently goes into ShouldRetryOn method.

Upvotes: 2

Views: 343

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172428

Try to set the connection string in web.config by setting Validate Connection = true. Also try to check the connection status == Open for connection received from the pool when you are doing the Connection.Open()

Also do check this source for the error you are getting

Question: I am attempting to connect to my Oracle database and I get the ORA-03135 error:

ORA-03135: connection lost contact tips

What can I do to avoid the ORA-03135 error?

Answer: The oerr utility shows this for the ORA-03135 error:

ORA-03135: connection lost contact

Cause: 1) Server unexpectedly terminated or was forced to terminate. or 2) Server timed out the connection.

Action: 1) Check if the server session was terminated. 2) Check if the timeout parameters are set properly in sqlnet.ora.

The ORA-03135 error is common when connecting remotely when a firewall terminates the connection.

One solution for the ORA-03135 error is to increase the value of the sqlnet.ora expire_time parameter in the sqlnet.ora file or to check for a expire parameter in a SQL*Plus profile.

To diagnose the ORA-03135 error, start by checking to see if the OS PID still exists, using the ps –ef|grep syntax.

Check to see if there is a Network Address Translation (NAT) between the client and server

In Windows, check to see if a Windows firewall is checking for your local connections:

Windows XP -> Control panel -> security -> Tab "Advanced"

Also, setting the parameters sqlnet.inbound_connect_timeout and inbound_connect_timeout_listenername to 0 can stop the ORA-03135 error.

Upvotes: 0

Related Questions