Fix ORA-16516 During Switchover in Oracle Data Guard (DGMGRL)

Introduction

While performing a switchover using Oracle Data Guard Broker, you may encounter the following error:

ORA-16516: current state is invalid for the attempted operation
Unable to switchover, primary database is still "PRIMARY"

This error is confusing because everything may appear perfectly configured — zero lag, apply running, and broker showing SUCCESS.

In this blog, we’ll explain the real root cause and exact fix.

The Problem Scenario

You attempt:

DGMGRL> SWITCHOVER TO STANDBY;
2026-03-22T08:16:44.263+00:00
Performing switchover NOW, please wait...
Error: ORA-16516: current state is invalid for the attempted operation
Failed.
2026-03-22T08:16:44.281+00:00
Unable to switchover, primary database is still "PRIMARY"
Why This Happens (Real Root Cause)
Even if your configuration looks correct:
✅ Transport Lag = 0
✅ Apply Lag = 0
✅ Standby Enabled
✅ Primary in READ WRITE
👉 The issue is usually:
⚠️ Standby is in READ ONLY WITH APPLY mode (Active Data Guard)
You can confirm this from:
DGMGRL> show database standby;
Database - standby
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 41 seconds ago)
Apply Lag: 0 seconds (computed 41 seconds ago)
Average Apply Rate: 5.00 KByte/s
Real Time Query: ON
Instance(s):
ORCL
Database Status:
SUCCESS

Solution (Step-by-Step Fix)


🟢 Step 1: Stop Redo Apply (DGMGRL)

EDIT DATABASE standby SET STATE='APPLY-OFF';

🟢 Step 2: Stop Managed Recovery (SQL)

Login to standby:

sqlplus / as sysdba
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

🟢 Step 3: Restart Standby in MOUNT Mode

shutdown immediate;
startup mount;

🟢 Step 4: Perform Switchover

Back in DGMGRL:

SWITCHOVER TO standby;

But it again fail then we connected to the primary database:

Check the Switch over status on Primary:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
NOT ALLOWED

After checking we verify that our MRP process is running on Standby Server

SQL> SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
PROCESS STATUS
--------- --------------------
DGRD ALLOCATED
DGRD ALLOCATED
ARCH CONNECTED
ARCH CONNECTED
ARCH CONNECTED
ARCH CONNECTED
MRP0 APPLYING_LOG

MRP0 is running, Then we check the transportaion service on the Primary server and check the paramter value log_archive

Show paramter log_archive_dest
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string RESET
log_archive_dest_state_20 string enable

Our parameter is in RESET state, we we enable this parameter

SQL> ALTER SYSTEM SET log_archive_dest_state_2=ENABLE;
System altered.

Then we check the switchover status from SQLPLUs


SWITCHOVER_STATUS
--------------------
RESOLVABLE GAP

-- After wait for few minutes  it change to to standby

SWITCHOVER_STATUS
--------------------
TO STANDBY




This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply