Search This Blog

Tuesday, July 6, 2010

Oracle error: ORA-02392: exceeded session limit on CPU usage, you are being logged off

This error occurs when during your Session with Oracle Database Server, you are performing lots of operations which consumes more and more of CPU time on the Oracle Database server, which exceeded the CPU_PER_SESSION setting/value (total CPU time in hundreds of seconds) of Profile your UserID has been assigned.

You can check this value for your UserID/Profile, by running query:
Select * From User_Resource_Limits

You may contact your DB Administrator and ask them to set CPU_PER_SESSION to UNLIMITED to resolve this issue. The Default Profile on Oracle DB has this value set to UNLIMITED already. So, you also have an option to set your UserID to Default Profile.

If your Organization does not allow you to set CPU_PER_SESSION setting/value to UNLIMITED, then you have a workaround. This is for .NET, but it shouldn't be hard to implement in any other programming language.

CODE:
try
{
    // Your code
}
catch (Exception dbExc)
{
    // Oracle: exceeded session limit on CPU usage, you are being logged off
     if (dbExc.Message.Contains("ORA-02392"))
     {
        System.Threading.Thread.Sleep(30000);
        }
        else
        throw dbExc;
}


Basically what you will be doing here is to Catch the Exception, identify it to confirm that it is the error about exceeded CPU usage, then put the current Thread to Sleep for say 30 seconds and then continue with your process flow. It will reconnect to the Oracle database and will work fine.Make sure that in your code you are checking the Connection state before executing your SQL. If the Connection is closed after returning from the Catch block, then just Open it and continue.

No comments:

Post a Comment