ORA-01089: Immediate Shutdown in Progress - Wait or Abort
ORA-01089: Immediate Shutdown in Progress
Section titled “ORA-01089: Immediate Shutdown in Progress”Error Overview
Section titled “Error Overview”Error Text: ORA-01089: immediate shutdown or close in progress - no operations are permitted
The ORA-01089 error is raised when a user or application attempts to perform a database operation after SHUTDOWN IMMEDIATE (or SHUTDOWN TRANSACTIONAL) has been issued. Oracle has started the shutdown sequence: it has stopped accepting new logins, has begun rolling back uncommitted transactions, and is waiting for that rollback to complete before closing and dismounting the database. Any operation attempted against the instance during this window — including queries — will receive ORA-01089.
Even privileged SYSDBA connections that are already established will receive this error for DML/DDL operations once the shutdown sequence has been initiated.
Common Causes
Section titled “Common Causes”1. SHUTDOWN IMMEDIATE Waiting on Active Transactions
Section titled “1. SHUTDOWN IMMEDIATE Waiting on Active Transactions”The most common scenario. One or more sessions had large uncommitted transactions when SHUTDOWN IMMEDIATE was issued. Oracle is rolling them back (which can take as long as the original transaction took to generate), and all operations are blocked until rollback completes.
2. SHUTDOWN TRANSACTIONAL Waiting for Sessions to Commit or Disconnect
Section titled “2. SHUTDOWN TRANSACTIONAL Waiting for Sessions to Commit or Disconnect”With SHUTDOWN TRANSACTIONAL, Oracle waits for all active transactions to commit or roll back on their own before proceeding. Sessions that remain connected with open transactions block the shutdown indefinitely until they complete or are killed.
3. Long-Running Jobs or Background Processes
Section titled “3. Long-Running Jobs or Background Processes”Scheduler jobs, Data Pump operations, RMAN backup sessions, or Streams/replication processes that were active when shutdown was initiated prolong the SHUTDOWN IMMEDIATE wait.
4. Hung or Zombie Sessions
Section titled “4. Hung or Zombie Sessions”Sessions that are in a wait state (network I/O wait, lock wait) may not respond to the shutdown signal promptly, leaving the instance in the shutdown-in-progress state for an extended period.
5. Application Receiving ORA-01089 After Reconnect Attempt
Section titled “5. Application Receiving ORA-01089 After Reconnect Attempt”An application detects a dropped connection and immediately attempts to reconnect, but the instance has not yet fully shut down. The reconnect fails with ORA-01089.
Diagnostic Queries
Section titled “Diagnostic Queries”Check Shutdown Progress
Section titled “Check Shutdown Progress”-- Connect as SYSDBA before issuing shutdown, or from another SYSDBA sessionSELECT instance_name, status, active_state, shutdown_pendingFROM v$instance;
-- active_state values:-- NORMAL - normal operation-- QUIESCING - ALTER SYSTEM QUIESCE RESTRICTED in progress-- QUIESCED - fully quiesced-- shutdown_pending = YES means a shutdown has been requestedIdentify Active Transactions Blocking Shutdown
Section titled “Identify Active Transactions Blocking Shutdown”-- Active uncommitted transactionsSELECT t.addr, t.xidusn, t.xidslot, t.xidsqn, t.used_ublk, t.used_urec, s.sid, s.serial#, s.username, s.status, s.last_call_et, s.programFROM v$transaction tJOIN v$session s ON t.ses_addr = s.saddrORDER BY t.used_ublk DESC;Find Long-Running Active Sessions
Section titled “Find Long-Running Active Sessions”-- Sessions with the longest elapsed time since last callSELECT sid, serial#, username, status, last_call_et, ROUND(last_call_et/60, 1) AS minutes_active, sql_id, program, machine, osuserFROM v$sessionWHERE username IS NOT NULL AND status = 'ACTIVE'ORDER BY last_call_et DESC;Check Rollback Progress During Shutdown
Section titled “Check Rollback Progress During Shutdown”-- Monitor undo usage — decreasing used_ublk indicates rollback is progressingSELECT t.xidusn, t.used_ublk, t.used_urec, s.sid, s.username, s.programFROM v$transaction tJOIN v$session s ON t.ses_addr = s.saddrORDER BY t.used_ublk DESC;
-- Also check SMON activity — it handles distributed transaction recoverySELECT name, description, stateFROM v$bgprocessWHERE name = 'SMON';Estimate Remaining Rollback Time
Section titled “Estimate Remaining Rollback Time”-- Compare undo blocks used over time to estimate rollback rate-- Run twice, 60 seconds apart, to get blocks/secondSELECT TO_CHAR(SYSDATE,'HH24:MI:SS') AS sample_time, SUM(used_ublk) AS total_undo_blocksFROM v$transaction;Check for Active RMAN or Data Pump Sessions
Section titled “Check for Active RMAN or Data Pump Sessions”-- RMAN sessions during shutdownSELECT sid, serial#, username, program, status, last_call_etFROM v$sessionWHERE program LIKE '%rman%' OR program LIKE '%RMAN%' OR program LIKE '%dmp%';
-- Data Pump jobsSELECT job_name, state, degree, attached_sessionsFROM dba_datapump_jobsWHERE state != 'NOT RUNNING';Step-by-Step Resolution
Section titled “Step-by-Step Resolution”1. Wait for Shutdown to Complete (Preferred)
Section titled “1. Wait for Shutdown to Complete (Preferred)”If the shutdown was intentional and transactions are rolling back, the correct action is to wait. Monitor progress with another SYSDBA session:
-- In a second SYSDBA session (already established before shutdown was issued):-- Check every 60 seconds whether transactions are shrinkingSELECT SUM(used_ublk) AS blocks_remainingFROM v$transaction;2. Kill Blocking Sessions to Speed Up SHUTDOWN IMMEDIATE
Section titled “2. Kill Blocking Sessions to Speed Up SHUTDOWN IMMEDIATE”-- Kill the largest transactions first to accelerate rollback completion-- (Must be executed from the SYSDBA session that initiated the shutdown,-- or from another SYSDBA session already logged on)ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
-- Kill all non-system active sessions in a loopBEGIN FOR s IN ( SELECT sid, serial# FROM v$session WHERE username IS NOT NULL AND username NOT IN ('SYS','SYSTEM') AND status = 'ACTIVE' ) LOOP BEGIN EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# || ''' IMMEDIATE'; EXCEPTION WHEN OTHERS THEN NULL; END; END LOOP;END;/3. Escalate to SHUTDOWN ABORT
Section titled “3. Escalate to SHUTDOWN ABORT”When SHUTDOWN IMMEDIATE is hung and cannot be resolved by killing sessions, escalate to SHUTDOWN ABORT. This is safe in modern Oracle because crash recovery runs automatically on the next STARTUP.
-- From the same SYSDBA session or a new one (if the original hangs):SHUTDOWN ABORT;
-- Immediately follow with a clean startup to perform instance recovery:STARTUP;
-- Oracle SMON will automatically perform crash recovery (roll forward + roll back)-- before opening the database. This is equivalent to a controlled crash recovery.4. Prevent Applications from Reconnecting During Shutdown
Section titled “4. Prevent Applications from Reconnecting During Shutdown”Before issuing a shutdown, put the listener into a state that stops new connections:
# Stop listener from accepting new connections (existing ones are unaffected)lsnrctl stop
# Or, using lsnrctl to suspend:lsnrctl services # confirm current state-- Prevent new logins at the database level before shutdownALTER SYSTEM ENABLE RESTRICTED SESSION;
-- Then kill existing sessions before issuing SHUTDOWN IMMEDIATE5. Handle ORA-01089 in Applications
Section titled “5. Handle ORA-01089 in Applications”Applications should treat ORA-01089 as a signal that the database is deliberately going offline:
import cx_Oracleimport time
try: cursor.execute(sql)except cx_Oracle.DatabaseError as e: error_obj, = e.args if error_obj.code == 1089: # Database is shutting down — back off and retry later print("Database shutdown in progress. Will retry in 60 seconds.") time.sleep(60) # Re-establish connection and retry else: raisePrevention Strategies
Section titled “Prevention Strategies”1. Pre-Shutdown Checklist
Section titled “1. Pre-Shutdown Checklist”-- Before issuing SHUTDOWN IMMEDIATE, always check:
-- 1. Active transactionsSELECT COUNT(*) AS active_transactions FROM v$transaction;
-- 2. Long-running sessionsSELECT sid, serial#, username, ROUND(last_call_et/60,1) AS minutes, status, programFROM v$sessionWHERE username IS NOT NULL AND last_call_et > 300 -- running > 5 minutesORDER BY last_call_et DESC;
-- 3. Active Scheduler jobsSELECT job_name, state, last_start_dateFROM dba_scheduler_running_jobs;
-- 4. Active Data Pump jobsSELECT job_name, state FROM dba_datapump_jobs WHERE state != 'NOT RUNNING';2. Graceful Pre-Shutdown Procedure
Section titled “2. Graceful Pre-Shutdown Procedure”-- Step 1: Block new loginsALTER SYSTEM ENABLE RESTRICTED SESSION;
-- Step 2: Wait for or gracefully terminate active jobsBEGIN DBMS_SCHEDULER.STOP_JOB(job_name => 'SCHEMA.LONG_RUNNING_JOB', force => TRUE);END;/
-- Step 3: Kill long-running user sessionsBEGIN FOR s IN (SELECT sid, serial# FROM v$session WHERE username IS NOT NULL AND username NOT IN ('SYS','SYSTEM') AND last_call_et > 60) LOOP BEGIN EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# || ''' IMMEDIATE'; EXCEPTION WHEN OTHERS THEN NULL; END; END LOOP;END;/
-- Step 4: Now issue SHUTDOWN IMMEDIATE — should complete quicklySHUTDOWN IMMEDIATE;3. Monitoring During Planned Maintenance
Section titled “3. Monitoring During Planned Maintenance”-- Create a monitoring job that fires during planned shutdown windows-- to alert if shutdown is taking longer than expectedCREATE OR REPLACE PROCEDURE check_shutdown_progress AS v_status VARCHAR2(20);BEGIN SELECT status INTO v_status FROM v$instance; IF v_status = 'STARTED' THEN DBMS_OUTPUT.PUT_LINE('Instance in NOMOUNT — startup/shutdown sequence active'); END IF;END;/Related Errors
Section titled “Related Errors”- ORA-01033 - Oracle Initialization or Shutdown in Progress
- ORA-01034 - Oracle Not Available (instance is fully down)
- ORA-01109 - Database Not Open
- ORA-01012 - Not Logged On (sessions dropped during shutdown)
- ORA-01013 - User Requested Cancel of Current Operation
Emergency Response
Section titled “Emergency Response”Quick Fixes
Section titled “Quick Fixes”-
Check current shutdown state
SELECT status, shutdown_pending FROM v$instance;SELECT SUM(used_ublk) FROM v$transaction; -
Kill all blocking user sessions
BEGINFOR s IN (SELECT sid, serial# FROM v$sessionWHERE username NOT IN ('SYS','SYSTEM') AND username IS NOT NULL) LOOPBEGINEXECUTE IMMEDIATE'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# || ''' IMMEDIATE';EXCEPTION WHEN OTHERS THEN NULL;END;END LOOP;END;/ -
Abort and restart
SHUTDOWN ABORT;STARTUP;
Post-Resolution Cleanup
Section titled “Post-Resolution Cleanup”-- Confirm database is open after STARTUP following SHUTDOWN ABORTSELECT name, open_mode FROM v$database;SELECT instance_name, status FROM v$instance;
-- Verify crash recovery completed (no messages about recovery in progress)-- Check alert log: adrci> show alert -tail 50
-- Open PDBs if applicableALTER PLUGGABLE DATABASE ALL OPEN;
-- Re-enable normal sessions if restricted mode was setALTER SYSTEM DISABLE RESTRICTED SESSION;