Thursday, September 24, 2015

Lock file left by a different patch, OPatch will not try re-using the lock file

Retrying a patch apply after a failed attempted resulted in following error.
$ /opt/app/11.2.0/grid4/OPatch/opatch apply -local
Oracle Interim Patch Installer version 11.2.0.3.6
Copyright (c) 2013, Oracle Corporation.  All rights reserved.

Oracle Home       : /opt/app/11.2.0/grid4
Central Inventory : /opt/app/oraInventory
   from           : /opt/app/11.2.0/grid4/oraInst.loc
OPatch version    : 11.2.0.3.6
OUI version       : 11.2.0.4.0
Log file location : /opt/app/11.2.0/grid4/cfgtoollogs/opatch/19852360_Sep_24_2015_13_35_27/apply2015-09-24_13-35-27PM_1.log

Applying interim patch '19852360' to OH '/opt/app/11.2.0/grid4'
Verifying environment and performing prerequisite checks...
[ Error during Oracle Home discovery Phase]. Detail: OPatchSession cannot load inventory for the given Oracle Home /opt/app/11.2.0/grid4. Possible causes are:
   No read or write permission to ORACLE_HOME/.patch_storage
   Central Inventory is locked by another OUI instance
   No read permission to Central Inventory
   The lock file exists in ORACLE_HOME/.patch_storage
   The Oracle Home does not exist in Central Inventory

[ Error during Oracle Home discovery Phase]. Detail: OPatch failed: ApplySession failed to prepare the system. Lock file left by a different patch, OPatch will not try re-using the lock file.
Log file location: /opt/app/11.2.0/grid4/cfgtoollogs/opatch/19852360_Sep_24_2015_13_35_27/apply2015-09-24_13-35-27PM_1.log

Recommended actions: Please make sure no other OPatch or OUI processes is running. Try running $ORACLE_HOME/oui/bin/runInstsaller.

OPatch failed with error code 22
Looking in the oraInventory showed a lock directory which was empty. Removing it didn't resolve the issue
[grid@rhel6m1 oraInventory]$ ls
backup  ContentsXML  locks  logs  oraInst.loc  orainstRoot.sh  oui
[grid@rhel6m1 oraInventory]$ cd locks/
[grid@rhel6m1 oraInventory]$ rmdir locks
Inside the .patch_storage there was another file patch_locked which had the information for which patch the lock is taken for
cat $ORACLE_HOME/.patch_storage/patch_locked
Locked for patch  :  21068539
Locked by class   :  rollback
Removing this file resolved the issue
rm $ORACLE_HOME/.patch_storage/patch_locked