title: ORA-04061: existing state of package body "PACKAGE.NAME" has been invalidated persists
body: <p>On one of Oracle DB instances I am working on I am observing a different than normal behavior when recompiling packages. </p>
  
  <p>Typically, (as in question <a href="https://stackoverflow.com/questions/1761595/frequent-error-in-oracle-ora-04068-existing-state-of-packages-has-been-discarde">Frequent error in Oracle ORA-04068: existing state of packages has been discarded</a>)  following error on first call is expected after PL/SQL package recompilation:</p>
  
  <pre><code>ERROR at line 1:
  ORA-04068: existing state of packages has been discarded
  ORA-04061: existing state of package body "PACKAGE.NAME" has been
  invalidated
  ORA-06508: PL/SQL: could not find program unit being called:
  "PACKAGE.NAME"
  ORA-06512: at line 1
  </code></pre>
  
  <p>But the second call should work fine, assuming the package has no errors of course. This behavior was present previously in that environment. In the meantime we upgraded from 11g R2 to 12c R1, and enabled edition based redefinition.</p>
  
  <p>Now the problem I am experiencing is that I keep getting just:</p>
  
  <pre><code>ORA-04061: existing state of package body "PACKAGE.NAME" has been
  invalidated
  ORA-06508: PL/SQL: could not find program unit being called:
  "PACKAGE.NAME"
  ORA-06512: at line 1
  </code></pre>
  
  <p>So no ORA-04068 anymore, and only way to fix it is to reconnect the session or calling DBMS_SESSION.RESET_PACKAGE() manually (but I don't control all code that may be affected anyway), otherwise the problem persists on every call.</p>
  
  <p>Are there any DB parameters that control this that could got tweaked? The problem is not specific to any particular PL/SQL package and it seems that it can be triggered by normal package invalidation when something it references, changes.</p>
  
  <p>Thank you in advance.</p>