ORA-27086: Unable to Lock File - Already in Use
ORA-27086: Unable to Lock File - Already in Use
Section titled “ORA-27086: Unable to Lock File - Already in Use”Error Overview
Section titled “Error Overview”Error Text: ORA-27086: unable to lock file - already in use
ORA-27086 is raised when Oracle tries to acquire an exclusive OS lock on a database file (datafile, controlfile, or log file) and another process has already locked it. This typically means another Oracle instance is using the file, or a stale lock remains from a previous instance crash.
Common Causes
Section titled “Common Causes”Two Instances Trying to Use Same File
Section titled “Two Instances Trying to Use Same File”- Standby database opened on same files as primary
- RAC misconfiguration where two instances think they own a file
- Cloned database started without renaming files
- Test instance started on production files
Stale Locks After Instance Crash
Section titled “Stale Locks After Instance Crash”- Instance crashed without releasing OS locks
- NFS lock daemon (lockd) holding stale lock
- Operating system did not clean up after process termination
- ASM instance crashed leaving lock files
NFS-Specific Issues
Section titled “NFS-Specific Issues”- NFS file locking misconfigured
- NLM (Network Lock Manager) not running
- Different mount options between nodes
- Lock file in
/var/lib/nfs/corrupted
Process Still Running
Section titled “Process Still Running”- Background process from previous startup still alive
- Shadow process holding file open
- Orphaned smon/pmon process
Diagnostic Steps
Section titled “Diagnostic Steps”Identify Holding Process
Section titled “Identify Holding Process”# Find process holding the filefuser -fv /u01/oradata/PROD/system01.dbf
# Or use lsoflsof /u01/oradata/PROD/system01.dbf
# All Oracle processes accessing filelsof | grep system01.dbfCheck for Other Instances
Section titled “Check for Other Instances”# All Oracle background processesps -ef | grep ora_pmon | grep -v grep
# Check if instance is registeredps -ef | grep -E "ora_smon|ora_dbw|ora_lgwr" | grep -v grep
# Multiple instances? Check SIDscat /etc/oratabVerify NFS Lock Status (if applicable)
Section titled “Verify NFS Lock Status (if applicable)”# Check NFS lock daemonsystemctl status nfs-serversystemctl status rpc-statd
# View active NFS locksshowmount -acat /var/lib/nfs/sm/*
# On NFS servershowmount -eCheck Alert Log
Section titled “Check Alert Log”tail -200 $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_$ORACLE_SID.log \ | grep -A5 "ORA-27086"Typical output:
ORA-27086: unable to lock file - already in useLinux-x86_64 Error: 11: Resource temporarily unavailableAdditional information: 8Additional information: 49152Resolution Steps
Section titled “Resolution Steps”1. Stop Other Instance
Section titled “1. Stop Other Instance”-- Identify which instance holds the file-- On suspect hostSELECT instance_name, status, host_nameFROM v$instance;
-- Shut down properlySHUTDOWN IMMEDIATE;
-- If hungSHUTDOWN ABORT;After shutdown, verify no orphan processes:
ps -ef | grep ora_ | grep -v grep# Should be empty for that instance2. Clean Up Stale Processes
Section titled “2. Clean Up Stale Processes”# Kill orphan Oracle processes (cautiously)ps -ef | grep "ora_pmon_$ORACLE_SID" | awk '{print $2}'
# Check shared memoryipcs -ma | grep oracle
# Remove orphan shared memory after instance fully downipcrm -m <shmid>
# Remove orphan semaphoresipcs -s | grep oracleipcrm -s <semid>WARNING: Only remove IPC resources after confirming no Oracle process owns them.
3. Restart NFS Lock Daemons
Section titled “3. Restart NFS Lock Daemons”# On Linuxsystemctl restart rpcbindsystemctl restart nfs-serversystemctl restart rpc-statd
# Clear stale lock staterm /var/lib/nfs/sm/<hostname>systemctl restart rpc-statd4. Mount Database in Correct Mode
Section titled “4. Mount Database in Correct Mode”-- For physical standby, use STANDBY modeSHUTDOWN IMMEDIATE;STARTUP MOUNT;ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
-- Don't open standby in read-write while primary is open-- Use Active Data Guard for read-only access:STARTUP;ALTER DATABASE OPEN READ ONLY;5. Resolve Cloned Database
Section titled “5. Resolve Cloned Database”-- If clone is using same files as source, recreate with new names-- Use RMAN DUPLICATE with DB_FILE_NAME_CONVERTRMAN> DUPLICATE TARGET DATABASE TO clonedb DB_FILE_NAME_CONVERT=('/u01/oradata/PROD','/u01/oradata/CLONE') LOGFILE '/u01/oradata/CLONE/redo01.log' SIZE 100M;6. RAC Specific - Check Cluster Lock
Section titled “6. RAC Specific - Check Cluster Lock”# Verify cluster ownershipcrsctl stat res -t
# Check OCR for database registrationocrdump /tmp/ocr.dmpgrep -i "database" /tmp/ocr.dmp
# Restart specific instancesrvctl stop instance -d PROD -i PROD1srvctl start instance -d PROD -i PROD1Common Scenarios
Section titled “Common Scenarios”Scenario 1: Standby Started in Wrong Mode
Section titled “Scenario 1: Standby Started in Wrong Mode”ORA-27086: unable to lock file - already in useFile: /u01/oradata/PROD/system01.dbfFix: Standby should be MOUNT or OPEN READ ONLY, not OPEN. Primary holds exclusive locks.
Scenario 2: Test on Production Files
Section titled “Scenario 2: Test on Production Files”DBA cloned ORACLE_HOME, test instance points to production datafiles.Fix: Verify db_create_file_dest and controlfile points to test paths only.
Scenario 3: After Instance Crash
Section titled “Scenario 3: After Instance Crash”After OOM-killed Oracle instance, can't restart:ORA-27086: unable to lock file - already in useFix: Clean up IPC resources (ipcrm), kill orphan processes, then restart.
Sample Output
Section titled “Sample Output”SQL> STARTUP;ORACLE instance started.Total System Global Area 4294967296 bytesORA-01102: cannot mount database in EXCLUSIVE mode
[oracle@host]$ ps -ef | grep ora_pmonoracle 12345 1 0 May08 ? 00:00:00 ora_pmon_PROD
# Existing PROD instance still runningSQL> ALTER DATABASE MOUNT;ALTER DATABASE MOUNT*ERROR at line 1:ORA-01122: database file 1 failed verification checkORA-01110: data file 1: '/u01/oradata/PROD/system01.dbf'ORA-01207: file is more recent than control file - old control fileORA-27086: unable to lock file - already in useLinux-x86_64 Error: 11: Resource temporarily unavailable
# Solution: shut down other instance first[oracle@otherhost]$ . oraenv # PROD[oracle@otherhost]$ sqlplus / as sysdbaSQL> SHUTDOWN IMMEDIATE;
# Now retrySQL> STARTUP; -- successPrevention Strategies
Section titled “Prevention Strategies”Distinct File Locations Per Environment
Section titled “Distinct File Locations Per Environment”- Production:
/u01/oradata/PROD/ - Test:
/u01/oradata/TEST/ - Clone:
/u01/oradata/CLONE/ - Never share filesystem paths between environments
Centralized Instance Registry
Section titled “Centralized Instance Registry”# /etc/oratab listing all instances on hostPROD:/u01/app/oracle/product/19c/dbhome_1:YTEST:/u01/app/oracle/product/19c/dbhome_1:N
# Verify uniquenessawk -F: '{print $1}' /etc/oratab | sort | uniq -d# Empty output = no duplicatesNFS Best Practices
Section titled “NFS Best Practices”# /etc/fstab - Oracle on NFSnfs-server:/oracle /u01/oradata nfs \ rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600 0 0Required NFS mount options (Oracle Doc ID 359515.1):
hard- retry on failurenointr- don’t allow signal interruptionactimeo=0- disable attribute caching for shared writes
Startup Validation Script
Section titled “Startup Validation Script”#!/bin/bash# Pre-startup checkSID=$1
# Check for existing instanceif pgrep -f "ora_pmon_$SID" > /dev/null; then echo "ERROR: Instance $SID already running" exit 1fi
# Check for orphan IPCif ipcs -m | grep oracle | grep -q "^"; then echo "WARN: Stale shared memory present" ipcs -m | grep oraclefi
echo "OK: Safe to start $SID"Standby Mode Discipline
Section titled “Standby Mode Discipline”- Use Data Guard Broker for state management
- Document who can open standby read-write (rare)
- Monitor primary/standby role consistency
Related Errors
Section titled “Related Errors”- ORA-01102: Cannot mount database in EXCLUSIVE mode
- ORA-01122: Database file [N] failed verification check
- ORA-09817: Write to audit file failed
- ORA-27037: Unable to obtain file status
- ORA-27041: Unable to open file
Troubleshooting Checklist
Section titled “Troubleshooting Checklist”- Identify file holder with
fuserorlsof - Check for other Oracle instances on same host/files
- Verify
ora_pmonprocesses for unexpected SIDs - Inspect IPC resources for stale entries
- Validate NFS lock daemon if file on NFS
- Restart NFS lockd if stale locks suspected
- Confirm standby in correct mode (MOUNT/READ ONLY)
- Clean up after crash before retry