Thursday, January 27, 2022

What to do if DATAPATCH is not Successful

DATAPATCH reports non-ignoreable errors were found during an apply or rollback.  Datapatch was executed to perform SQL patch apply or rollback but there are non-ignorable errors. The cause is that During the apply or rollback, DATPATCH found errors in a log file

For example:

Errors during an APPLY

$ datapatch -verbose

Patch 12345678 APPLY: WITH ERRORS
catbundle apply logfile: /u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ORCL_ORCL_APPLY_2022Jan26_22_22_22.log (errors)

Additionally, the view  dba_registry_sqlpatch will show "WITH ERRORS"

SQL> select PATCH_ID, ACTION, STATUS,ACTION_TIME DESCRIPTION  from dba_registry_sqlpatch ORDER BY 
ACTION_TIME DESC;

SQL> SELECT * FROM PDB_PLUG_IN_VIOLATIONS;


PATCH_ID   ACTION     STATUS          ACTION_TIME                DESCRIPTION
---------- ---------- --------------- ---------------------------------------
  12345678 APPLY      WITH ERRORS   26-JAN-2022 22.22.22. PM   bundle:PSU

Errors during a ROLLBACK

Errors returned by datapatch

datapatch -verbose

Patch 12345678 ROLLBACK: WITH ERRORS

Additionally, the view  dba_registry_sqlpatch will show "WITH ERRORS"

SQL> select PATCH_ID, ACTION, STATUS,ACTION_TIME DESCRIPTION  from dba_registry_sqlpatch ORDER BY 
ACTION_TIME DESC;

SQL> SELECT * FROM PDB_PLUG_IN_VIOLATIONS;

PATCH_ID    ACTION     STATUS          ACTION_TIME                DESCRIPTION
---------- ---------- --------------- ---------------------------------------
  12345678  APPLY      WITH ERRORS   26-JAN-2022 23.23.23. PM   bundle:PSU

==>Solution for errors during an apply

Fix the issue and rerun SQL apply

  1. Resolve the issue causing the SQL error
  2. Rerun datapatch
% datapatch -verbose

Rollback patch from ORACLE_HOME and rollback SQL from db (via force rollback)


NOTE: Should a patch be rolled back from the ORACLE_HOME having a dba_registry_sqlpatch STATUS of "WITH ERROR", datapatch will not re-execute the SQL necessary to rollback the SQL to the database unless the -force  option is utilized.  The datapatch output will be similar to:

    Connecting to database...OK
    Determining current state...
    Currently installed SQL Patches:
    Currently installed C Patches:
    Nothing to roll back
    Nothing to apply
    SQL Patching tool complete on Thu Jan  26 22:22:22 2022

  1. Rollback the patch from the ORACLE_HOME
  2. Rerun datapatch with the force option
% datapatch -rollback < patch number > -force -verbose

The datapatch output will be similar to:

% datapatch -rollback 17552800 -force -verbose

dba_registry_sqlpatch will now show:

PATCH_ID ACTION     STATUS          ACTION_TIME           DESCRIPTION
  12345678 APPLY      WITH ERRORS     26-JAN-22 22.2.22 PM   bundle:PSU
  12345678 ROLLBACK   SUCCESS         26-JAN-22 23.23.23 PM  bundle:PSU

==>Solution for errors during a rollback
Fix the issue and rerun SQL rollback
  1. Resolve the issue causing the SQL error
  2. Rerun datapatch

% datapatch -verbose

dba_registry_sqlpatch will now show:

PATCH_ID ACTION     STATUS          ACTION_TIME                    DESCRIPTION

  12345678 APPLY      SUCCESS         26-JAN-22 07.09.49.755424 PM   bundle:PSU

  12345678 ROLLBACK   WITH ERRORS     26-JAN-22 07.15.58.746868 PM   bundle:PSU

  12345678 ROLLBACK   SUCCESS         26-JAN-22 08.58.14.104658 PM   bundle:PSU

Resolve the issue causing the SQL errors and reinstall the patch

NOTE: Should a patch be reinstalled to the ORACLE_HOME having a dba_registry_sqlpatch STATUS of "WITH ERROR", datapatch will not re-execute the SQL necessary to apply the SQL to the database unless the -force  option is utilized.  The datapatch output will be similar to:

    Connecting to database...OK
    Determining current state...
    Currently installed SQL Patches: 17552800
    C patch 17027533 is a bundle patch and prereq for a later bundle
    Currently installed C Patches: 17552800
    Nothing to roll back
    Nothing to apply

  1. Resolve the issue causing the SQL error
  2. Reinstall the patch to the ORACLE_HOME
  3. Rerun datapatch with the force option

% datapatch -apply < patch number > -force -verbose

dba_registry_sqlpatch will now show:

PATCH_ID ACTION     STATUS          ACTION_TIME                    DESCRIPTION

  12345678 APPLY      SUCCESS         26-JAN-22 07.09.49.755424 PM   bundle:PSU

  12345678 ROLLBACK   WITH ERRORS     26-JAN-22 07.15.58.746868 PM   bundle:PSU

  12345678 APPLY      SUCCESS         26-JAN-22 08.36.33.355797 PM   bundle:PSU