ORA-44787: Service cannot be switched into on Oracle 12c PDB

If you encounter ORA-44787 when switching to PDB using alter session set container, main reason for same can be the unavailability of default PDB service. When a PDB is enabled it does starts its own default PDB service with service name set to the PDB name. Although it is possible to create new service for PDB using DBMS_SERVICE.create_service, it is required to keep the default service up and running as it is used by internal operations. If you have stopped the default service it is the main reason for this particular error.

Below is a simple example where stopping of default PDB service leads to ORA-44787

Creating the new service

 SQL> alter session set container=ORCLPDB;  
 Session altered.  
 SQL> BEGIN  
  DBMS_SERVICE.create_service(  
   service_name => 'new_service',  
   network_name => 'NEW_SERVICE'  
  );  
  END;  2  3  4  5  6  
  7 /  
 PL/SQL procedure successfully completed.  
 SQL> exec dbms_service.start_service('new_service');  
 PL/SQL procedure successfully completed.  
 SQL>  

Now this new service can be used to connect to the database. Also untile you have the default services running alter session set container should work without any issue.

Stopping the default service

 SQL> alter session set container=ORCLPDB;  
 Session altered.  
 SQL> SELECT NAME FROM V$ACTIVE_SERVICES;  
 NAME  
 ----------------------------------------------------------------  
 new_service  
 orclpdb  
 SQL> exec DBMS_SERVICE.STOP_SERVICE('orclpdb');  
 PL/SQL procedure successfully completed.  
 SQL>   
 </code>  
 Now if you try to switch to the PDB it will faile with ORA-44787.  
 SQL> show pdbs;  
   CON_ID CON_NAME            OPEN MODE RESTRICTED  
 ---------- ------------------------------ ---------- ----------  
      2 PDB$SEED            MOUNTED  
      3 ORCLPDB            READ WRITE NO  
 SQL> alter session set container=ORCLPDB;  
 ERROR:  
 ORA-44787: Service cannot be switched into.  
 SQL> exit  
Although the switch to PDB fails external connections using the new service name will working. But this can cause manageability issues.
A quick fix would be to restart the PDB using below steps.
 SQL> show pdbs;  
   CON_ID CON_NAME            OPEN MODE RESTRICTED  
 ---------- ------------------------------ ---------- ----------  
      2 PDB$SEED            MOUNTED  
      3 ORCLPDB            READ WRITE NO  
 SQL> alter pluggable database "ORCLPDB" close;  
 Pluggable database altered.  
 SQL> show pdbs;  
   CON_ID CON_NAME            OPEN MODE RESTRICTED  
 ---------- ------------------------------ ---------- ----------  
      2 PDB$SEED            MOUNTED  
      3 ORCLPDB            MOUNTED  
 SQL> alter session set container=ORCLPDB;  
 Session altered.  
 SQL> startup;  
 Pluggable Database opened.  
 SQL> exit  
 Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production  
 ora12c@racbprdb1:~$ sqlplus sys as sysdba  
 SQL*Plus: Release 12.2.0.1.0 Production on Mon Aug 10 13:51:37 2020  
 Copyright (c) 1982, 2016, Oracle. All rights reserved.  
 Enter password:  
 Connected to:  
 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production  
 SQL> show pdbs;  
   CON_ID CON_NAME            OPEN MODE RESTRICTED  
 ---------- ------------------------------ ---------- ----------  
      2 PDB$SEED            MOUNTED  
      3 ORCLPDB            READ WRITE NO  
 SQL> alter session set container=ORCLPDB;  
 Session altered.  
 SQL> show pdbs;  
   CON_ID CON_NAME            OPEN MODE RESTRICTED  
 ---------- ------------------------------ ---------- ----------  
      3 ORCLPDB            READ WRITE NO  
 SQL>   


Comments

Popular posts from this blog

ORA-16433: The database or pluggable database must be opened in read/write

Wait for unread message on broadcast channel - Blocking Sessions

ORA-14126 - While splitting max value partition