Home » SQL & PL/SQL » SQL & PL/SQL » ORA-04068: existing state of packages has been discarded (Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production, Linux Redhat)
ORA-04068: existing state of packages has been discarded [message #677209] Fri, 30 August 2019 10:29 Go to next message
fixxxer
Messages: 41
Registered: August 2014
Member
We use edition based redefinition.

We have a package that has absolutely no package variables, constants, cursors. It simply has 1 procedure within the package.

I've checked to see if the package has state, and it does not (Execute the package procedure from session 1, compile the package in session 2, run the package procedure again in session 1 - no problem).

Out application team are interacting with this package procedure via JDBC. They are intermittently getting "ORA-04068: existing state of packages has been discarded".

Honestly stuck on trying to diagnose the problem. Enabled DDL audit on, and there is nothing running at that time that would indicate the cause of this issue.

Just wanting to see if anyone has come across this before?

Let me know if you need any more details.
Re: ORA-04068: existing state of packages has been discarded [message #677222 is a reply to message #677209] Mon, 02 September 2019 05:05 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
Are you sure JDBC is complaining about the package you think it is?
Because if the situation is really as you describe the only thing I think is that you've hit an oracle bug - in which case you really need to talk to oracle support.
Re: ORA-04068: existing state of packages has been discarded [message #677225 is a reply to message #677222] Mon, 02 September 2019 05:16 Go to previous messageGo to next message
fixxxer
Messages: 41
Registered: August 2014
Member
Thanks for the reply.

Yeah, the error message references the same package every time:

ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped package body "XXX.XXX"
ORA-06508: PL/SQL: could not find program unit being called: "XXX.XXX"

We have opened an SR with ORACLE, as it is strange behavior. Feel it may be something to do with Edition Based Redefinition.
Re: ORA-04068: existing state of packages has been discarded [message #677226 is a reply to message #677225] Mon, 02 September 2019 05:18 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
Does the package call other packages?
Cause it may well be that the call to the package in question is throwing the last two errors because some other package further down the stack is throwing the first error.
Re: ORA-04068: existing state of packages has been discarded [message #677227 is a reply to message #677226] Mon, 02 September 2019 05:24 Go to previous messageGo to next message
fixxxer
Messages: 41
Registered: August 2014
Member
Yeah it calls some instrumentation packages, for debug e.t.c. However, we have exception handling that would wrap the error in our own formatting. The application is failing to even invoke the package, as it's state is no longer valid (even though it is written as a stateless package).

It succeeds on the 2nd call after it re-instantiates the package.
Re: ORA-04068: existing state of packages has been discarded [message #685535 is a reply to message #677227] Tue, 01 February 2022 17:55 Go to previous messageGo to next message
farasatdba
Messages: 1
Registered: February 2022
Junior Member
Can you please provide the fix, We have the same kind of issue while calling the package and its using the exception:
Re: ORA-04068: existing state of packages has been discarded [message #685536 is a reply to message #685535] Wed, 02 February 2022 00:18 Go to previous messageGo to next message
Michel Cadot
Messages: 68205
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

"Fix" is already given: call again the package when you have this error.
But then raise a question: why a package is modified/recompiled when it is in use?
If this is necessary (24/24 7/7 case) then you should think to use editions.

Re: ORA-04068: existing state of packages has been discarded [message #685537 is a reply to message #685535] Wed, 02 February 2022 03:38 Go to previous message
fixxxer
Messages: 41
Registered: August 2014
Member
The change we implemented was for the application to have a retry policy in the event of such exception. We did not resolve it at an edition/DB level.
Previous Topic: transpose logic
Next Topic: Print value in table columns dynamically
Goto Forum:
  


Current Time: Tue Jun 28 17:37:42 CDT 2022