ORA-16816: incorrect database role

In Data Guard, for some reason, standby database rule are incorrectly shown as primary database, while primary database shows as standby rule.

DGMGRL> show configuration;

Configuration - TESTDB
  Protection Mode: MaxPerformance
  Databases:
    TESTDBSTY - Primary database
      Error: ORA-16810: multiple errors or warnings detected 
             for the database

     TESTDB - Physical standby database
      Error: ORA-16810: multiple errors or warnings detected 
             for the database

Fast-Start Failover: DISABLED

Configuration Status:
ERROR 


DGMGRL> show database "TESTDBSTY";

Database - TESTDBSTY

Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s): TESTDBSTY
Error: ORA-16782: instance not open for read and write access
Database Error(s):
ORA-16816: incorrect database role

Database Status:
ERROR

How to fix it ?

Subscribe to get access

Read more of this content when you subscribe today.

ORA-16849 ORA-16816 After Uncompleted Data Guard Switchover

For some reason, DG ( Data Guard ) switchover command is incomplete with following warnings:

Database Error(s):
 ORA-16849: a previous switchover from this database was interrupted 
            and aborted
 ORA-16816: incorrect database role

After detailed checks, it is confirmed that database role has been changed successfully.

-- on old primary database
--
SQL> select open_mode, database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
MOUNTED              PHYSICAL STANDBY

-- on old standby database
--
SQL> select open_mode, database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
MOUNTED              PRIMARY

So the issues is the final role change has not been recognized by the DG broker, so we have to rebuild the Data Guard Broker Configuration when the Databases have been restarted:

DGMGRL> remove configuration;
DGMGRL> create configuration 'PRIMDB' AS PRIMARY DATABASE IS 
       'PRIMDB' CONNECT IDENTIFIER IS 'PRIMDB'; 
DGMGRL> add database 'STDBYDB' AS CONNECT IDENTIFIER IS 'STDBYDB' 
        maintained as physical;
DGMGRL> enable configuration;
DGMGRL> show configuration;
DGMGRL> show database verbose 'PRIMDB';
DGMGRL> show database verbose 'STDBYDB';