Oracle Database Proactive Patch 12.1.0.2.190716 failing with ORA-04068 ORA-04061 ORA-04065

Those days, I was updating some of my lab environments running Oracle Database 12.1.0.2 to the 190716 quarterly update Bundle Patch. However, during the Datapatch execution phase, I was getting some ORA errors.

Patch 29496791 apply (pdb CDB$ROOT): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/29496791/22993732/29496791_apply_ORCL_CDBROOT_2019Jul31_11_55_12.log (no errors)
Patch 29496791 apply (pdb PDB$SEED): WITH ERRORS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/29496791/22993732/29496791_apply_ORCL_PDBSEED_2019Jul31_11_58_00.log (errors)
    Error at line 26523: ORA-04068: existing state of packages has been discarded
    Error at line 26524: ORA-04061: existing state of package body "SYS.DBMS_REGISTRY_SYS" has been
    Error at line 26526: ORA-04065: not executed, altered or dropped package body
    Error at line 26528: ORA-06508: PL/SQL: could not find program unit being called:
    Error at line 33825: ORA-20000: Insufficient privileges to analyze an object in Dictionary Schema
Patch 29496791 apply (pdb PDB01): WITH ERRORS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/29496791/22993732/29496791_apply_ORCL_PDB01_2019Jul31_11_58_00.log (errors)
    Error at line 26330: ORA-04068: existing state of packages has been discarded
    Error at line 26331: ORA-04061: existing state of package body "SYS.DBMS_REGISTRY_SYS" has been
    Error at line 26333: ORA-04065: not executed, altered or dropped package body
    Error at line 26335: ORA-06508: PL/SQL: could not find program unit being called:
    Error at line 33632: ORA-20000: Insufficient privileges to analyze an object in Dictionary Schema

Checking the datapatch log file, I could find it was related with OLS:

SQL> EXECUTE DBMS_REGISTRY.LOADING('OLS', 'Oracle Label Security', 'validate_ols', 'LBACSYS');
BEGIN DBMS_REGISTRY.LOADING('OLS', 'Oracle Label Security', 'validate_ols', 'LBACSYS'); END;
*
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SYS.DBMS_REGISTRY_SYS" has been invalidated
ORA-04065: not executed, altered or dropped package body "SYS.DBMS_REGISTRY_SYS"

After some research, I've found the following note:

And it states:

In certain situations the Post-install actions (datapatch -verbose) may fail for DBBP 12.1.0.2.190716:

Error at line 26397: ORA-04068: existing state of packages has been discarded
Error at line 26398: ORA-04061: existing state of package body "SYS.DBMS_REGISTRY_SYS" has been
Error at line 26400: ORA-04065: not executed, altered or dropped package body
Error at line 26402: ORA-06508: PL/SQL: could not find program unit being called:
Error at line 33699: ORA-20000: Insufficient privileges to analyze an object in Dictionary Schema

When this occurs, it is simply a consequence of the order that certain actions are performed within the "datapatch" process. The workaround is simply to run 'datapatch –verbose' a second time.

A fix for this will be included into a future quarterly DBBP.

So basically, a datapatch rerun should fix this issue..

Let's run it again:

SQL Patching tool version 12.1.0.2.0 Production on Wed Jul 31 12:56:18 2019
Copyright (c) 2012, 2017, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_14491_2019_07_31_12_56_18/sqlpatch_invocation.log

Connecting to database...OK
Note:  Datapatch will only apply or rollback SQL fixes for PDBs
       that are in an open state, no patches will be applied to closed PDBs.
       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
       (Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done

Queryable inventory could not determine the current opatch status.
Execute 'select dbms_sqlpatch.verify_queryable_inventory from dual'
and/or check the invocation log
/u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_14491_2019_07_31_12_56_18/sqlpatch_invocation.log
for the complete error.
Prereq check failed, exiting without installing any patches.

Please refer to MOS Note 1609718.1 and/or the invocation log
/u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_14491_2019_07_31_12_56_18/sqlpatch_invocation.log
for information on how to resolve the above errors.

SQL Patching tool complete on Wed Jul 31 12:56:29 2019

Now I got a different error. However, if I run for a third time:

SQL Patching tool version 12.1.0.2.0 Production on Wed Jul 31 12:56:29 2019
Copyright (c) 2012, 2017, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_14802_2019_07_31_12_56_29/sqlpatch_invocation.log

Connecting to database...OK
Note:  Datapatch will only apply or rollback SQL fixes for PDBs
       that are in an open state, no patches will be applied to closed PDBs.
       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
       (Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of SQL patches:
Bundle series DBBP:
  ID 190716 in the binary registry and ID 190716 in PDB CDB$ROOT, ID 190716 with errors in PDB PDB$SEED, ID 190716 with errors in PDB PDB01

Adding patches to installation queue and performing prereq checks...
Installation queue:
  For the following PDBs: CDB$ROOT
    Nothing to roll back
    Nothing to apply
  For the following PDBs: PDB$SEED PDB01
    Nothing to roll back
    The following patches will be applied:
      29496791 (DATABASE BUNDLE PATCH 12.1.0.2.190716)

Installing patches...
Patch installation complete.  Total patches installed: 2

Validating logfiles...
Patch 29496791 apply (pdb PDB$SEED): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/29496791/22993732/29496791_apply_ORCL_PDBSEED_2019Jul31_12_56_57.log (no errors)
Patch 29496791 apply (pdb PDB01): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/29496791/22993732/29496791_apply_ORCL_PDB01_2019Jul31_12_56_57.log (no errors)
SQL Patching tool complete on Wed Jul 31 12:59:03 2019

That's it, if you face the error above, just rerun your datapatch 2 more times and you will be fine.

Have you enjoyed? Please leave a comment or give a 👍!

3 comments

    • Piyush on September 13, 2019 at 12:24
    • Reply

    can you please share the link to download this patch? I want to update my oracle database from 11.2.0.4 to 12.2.0.1.190716

    1. No, all patches are available only via My Oracle Support per licence policy.

    • Stormy on October 16, 2020 at 18:11
    • Reply

    you need patch for bug 31413047, then datapatch apply will not fail.

Leave a Reply

Your email address will not be published.