Friday, 19 May 2023

Creating and managing Oracle services in single instance Non RAC Systems.

 Creating and managing Oracle services in single instance Non RAC Systems.


#At first lets try to create a service with srvctl :


SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 PDB1                           READ WRITE NO


SQL> show parameter uniq


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_unique_name                       string      orcl


[oracle@node2 ~]$ srvctl status database -d orcl

****Unable to retrieve Oracle Clusterware home.

Start Oracle Clusterware stack and try again.



[oracle@node2 ~]$ srvctl add service -s s1 -d orcl

****Unable to retrieve Oracle Clusterware home.

Start Oracle Clusterware stack and try again.



# This clearly means you cannot manage services in non rac single instance systems with srvctl. The srvctl works with Grid Infrastructure and is the recommended way in Grid Infrastructure. However if you are in non RAC systems then use dbms_service to create and manage services.


Lets create a service now, the version we are using is 21c :


[oracle@node2 dk]$ sqlplus / as sysdba


SQL*Plus: Release 21.0.0.0.0 - Production on Fri May 19 23:31:37 2023

Version 21.3.0.0.0


Copyright (c) 1982, 2021, Oracle.  All rights reserved.



Connected to:

Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production

Version 21.3.0.0.0


SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 PDB1                           READ WRITE NO



    BEGIN

      DBMS_SERVICE.create_service(

        service_name => 'service1',

        network_name => 'service1'

     );

   END;

SQL> /


PL/SQL procedure successfully completed.


# Lets see how to start a service 



SQL> exec dbms_service.start_service('service1');


PL/SQL procedure successfully completed.


# Lets see how to stop a service 



SQL> exec dbms_service.stop_service('service1');


PL/SQL procedure successfully completed.


# Lets see how to delete a service 



SQL> exec dbms_service.delete_service('service1');

BEGIN dbms_service.delete_service('service1'); END;


*

ERROR at line 1:

ORA-44305: service service1 is running

ORA-06512: at "SYS.DBMS_SERVICE", line 68

ORA-06512: at "SYS.DBMS_SERVICE", line 458

ORA-06512: at line 1



# You cannot delete a running service in Oracle.

# So you must stop it first, lets try it


SQL>  exec dbms_service.stop_service('service1');


PL/SQL procedure successfully completed.


SQL> exec dbms_service.delete_service('service1');


PL/SQL procedure successfully completed.


# It works now.


# Lets try to connect now :


SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 PDB1                           READ WRITE NO


# I am connected in the CDB$ROOT 


SQL> show con_name


CON_NAME

------------------------------

CDB$ROOT



# Create a user 


SQL> create user user1 identified by Oracle123mine ;

create user user1 identified by Oracle123mine

            *

ERROR at line 1:

ORA-65096: invalid common user or role name



SQL> create user c##user1 identified by Oracle123mine ;


User created.


SQL> grant connect to c##user1;


Grant succeeded.



[oracle@node2 dk]$ sqlplus c##user1@service1


SQL*Plus: Release 21.0.0.0.0 - Production on Fri May 19 23:36:57 2023

Version 21.3.0.0.0


Copyright (c) 1982, 2021, Oracle.  All rights reserved.


Enter password:


Connected to:

Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production

Version 21.3.0.0.0






Wednesday, 10 May 2023

Automatic Transaction Rollback feature in 23C

 Automatic Transaction Rollback feature in 23C

The Row lock contention has been a major pain area for developers specially when it comes to releasing locks in case there is an exception thrown by a transaction from an application. The developers in most cases take help from the DBAs to kill their blocking parent session or in essense kill the final blocking session if there is a chain of row locks under the lock tree.


The Automatic Transaction Rollback feature automatically rolls back low-priority transactions that are blocking higher priority transactions from obtaining row locks.


This parameter is one of four initialization parameters that enable you to configure Automatic Transaction Rollback. The other parameters are:


TXN_PRIORITY - Specifies a priority (HIGH, MEDIUM, or LOW) for all transactions in a user session


TXN_AUTO_ROLLBACK_MEDIUM_PRIORITY_WAIT_TARGET - Specifies the maximum number of seconds that a MEDIUM priority transaction will wait for a row lock


TXN_AUTO_ROLLBACK_MODE - Specifies whether to enable Automatic Transaction Rollback or test Automatic Transaction Rollback by running in tracking mode


Note: This parameter is available starting with Oracle Database 23c.


Lets see what wait events have been introduced with the 23c version :


SQL> select event#, name, WAIT_CLASS from v$event_name where name like '%TX - row%';


    EVENT# NAME                                                             WAIT_CLASS

---------- ---------------------------------------------------------------- ----------------------------------------------------------------

       340 enq: TX - row lock contention                                    Application

       341 enq: TX - row lock (HIGH priority)                               Application

       342 enq: TX - row lock (MEDIUM priority)                             Application

       343 enq: TX - row lock (LOW priority)                                Application


The parameter txn_auto_rollback_medium_priority_wait_target default value is 2147483647, The TXN_AUTO_ROLLBACK_HIGH_PRIORITY_WAIT_TARGET specifies the maximum number of seconds that a HIGH priority transaction will wait for a row lock before the Automatic Transaction Rollback feature rolls back a lower priority transaction holding the lock.



SQL> show parameter TXN_AUTO_ROLLBACK_MEDIUM_PRIORITY_WAIT_TARGET


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

txn_auto_rollback_medium_priority_wa integer     2147483647

it_target

SQL> col NAME For a100

SQL> show parameter TXN_AUTO_ROLLBACK_MEDIUM_PRIORITY_WAIT_TARGET


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

txn_auto_rollback_medium_priority_wa integer     2147483647

it_target

SQL>


# Now since this is a static parameter, it needs a database restart.


SQL> alter system set txn_auto_rollback_medium_priority_wait_target=50 scope=spfile;


System altered.


SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.


Total System Global Area 1608409424 bytes

Fixed Size                 10043728 bytes

Variable Size             402653184 bytes

Database Buffers         1191182336 bytes

Redo Buffers                4530176 bytes

Database mounted.

Database opened.


Lets confirm the value :


SQL> show parameter TXN_AUTO_ROLLBACK_MEDIUM_PRIORITY_WAIT_TARGET


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

txn_auto_rollback_medium_priority_wa integer     50


Session 1 with Medium priority: 


SQL> select * from t1;


         I         I2

---------- ----------

         1          1

         2          2

         3          3

         4          4

         5          5


SQL>  alter session set TXN_PRIORITY=MEDIUM;


Session altered.


SQL> update t1 set i=11 where i=1;


1 row updated.



Session 2 with High Priority: 


SQL> alter session set TXN_PRIORITY=HIGH;


Session altered.


SQL> show parameter TXN_AUTO_ROLLBACK_MEDIUM_PRIORITY_WAIT_TARGET


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

txn_auto_rollback_medium_priority_wa integer     50


SQL> select * from t1;


         I         I2

---------- ----------

         1          1

         2          2

         3          3

         4          4

         5          5


SQL> update t1 set i=1001 where i=1;


>>> Hangs here >>>>>





Session 3 DBA session Monitors the wait :


SQL> select sid,EVENT,WAIT_CLASS,WAIT_TIME,SECONDS_IN_WAIT,STATE from v$session_wait where event like '%lock%';


       SID EVENT                                    WAIT_CLASS            WAIT_TIME SECONDS_IN_WAIT STATE

---------- ---------------------------------------- -------------------- ---------- --------------- -------------------

       112 enq: TX - row lock (HIGH priority)       Application                   0              22 WAITING



SQL> select sid,EVENT,WAIT_CLASS,WAIT_TIME,SECONDS_IN_WAIT,STATE from v$session_wait where event like '%lock%';


       SID EVENT                                    WAIT_CLASS            WAIT_TIME SECONDS_IN_WAIT STATE

---------- ---------------------------------------- -------------------- ---------- --------------- -------------------

       112 enq: TX - row lock (HIGH priority)       Application                   0             49 WAITING



Now go to session 1, the one with MEDIUM priority :


SQL> select * from t1;

select * from t1

       *

ERROR at line 1:

ORA-03135: connection lost contact

Process ID: 1043

Session ID: 31 Serial number: 10449



Now go to session 2 >> High Priority session :


SQL> update t1 set i=1001 where i=1;





1 row updated.


SQL> 

SQL> select * from t1;


         I         I2

---------- ----------

      1001          1

         2          2

         3          3

         4          4

         5          5


# This clearly explains how high priority session takes priority over low priority sessions. Happy 23C #Oracle.





How to create a database in 23C

 Creating a database in 23C :


Let us see how we can create a database in Oracle 23c free version for developers :


login as: root

root@192.9.201.121's password:

Activate the web console with: systemctl enable --now cockpit.socket


Register this system with Red Hat Insights: insights-client --register

Create an account or view all your systems at https://red.ht/insights-dashboard

Last login: Wed May 10 22:03:56 2023

[root@node1-example-com ~]# export DB_PASSWORD=Oracle123mine

[root@node1-example-com ~]# (echo "${DB_PASSWORD}"; echo "${DB_PASSWORD}";) | /etc/init.d/oracle-free-23c configure

Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:

Confirm the password:

Configuring Oracle Listener.

Listener configuration succeeded.

Configuring Oracle Database FREE.

Enter SYS user password:

************

Enter SYSTEM user password:

*************

Enter PDBADMIN User Password:

***************

Prepare for db operation

7% complete

Copying database files

29% complete

Creating and starting Oracle instance

30% complete

33% complete

36% complete

39% complete

43% complete

Completing Database Creation

47% complete

49% complete

50% complete

Creating Pluggable Databases

54% complete

71% complete

Executing Post Configuration Actions

93% complete

Running Custom Scripts

100% complete

Database creation complete. For details check the logfiles at:

 /opt/oracle/cfgtoollogs/dbca/FREE.

Database Information:

Global Database Name:FREE

System Identifier(SID):FREE

Look at the log file "/opt/oracle/cfgtoollogs/dbca/FREE/FREE.log" for further details.


Connect to Oracle Database using one of the connect strings:

     Pluggable database: node1-example-com/FREEPDB1

     Multitenant container database: node1-example-com


So how do we login to the Oracle 23c Database :


[root@node1-example-com ~]# su - oracle

[oracle@node1-example-com ~]$ export ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree

[oracle@node1-example-com ~]$ sqlplus sys/Oracle123mine@//localhost:1521/free as sysdba

bash: sqlplus: command not found...

[oracle@node1-example-com ~]$ ps -ef | grep smon

oracle     11268       1  0 22:49 ?        00:00:00 db_smon_FREE

oracle     11805   11758  0 22:55 pts/2    00:00:00 grep --color=auto smon

[oracle@node1-example-com ~]$  . oraenv

ORACLE_SID = [oracle] ? FREE

The Oracle base has been set to /opt/oracle

[oracle@node1-example-com ~]$ sqlplus / as sysdba


SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Wed May 10 22:56:01 2023

Version 23.2.0.0.0


Copyright (c) 1982, 2023, Oracle.  All rights reserved.


Connected to:

Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release

Version 23.2.0.0.0


SQL> SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 FREEPDB1                       READ WRITE NO


Thats it, Enjoy 23c  :) :)



Install Oracle 23c database free for Developers

 In this article we will learn how to Install Oracle 23c database free for Developers

First, get your downloaded files i.e :

oracle-database-free-23c-1.0-1.el8.x86_64.rpm

oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm


The above files can be downloaded from Oracle's web site : 


https://www.oracle.com/database/free/


[root@node1-example-com Documents]# ls -ltr

total 1717556

-rwxrw-rw-. 1 root root 1758776440 May 10 22:03 oracle-database-free-23c-1.0-1.el8.x86_64.rpm



[root@node1-example-com Documents]# rpm -ivh oracle-database-free-23c-1.0-1.el8.x86_64.rpm 

warning: oracle-database-free-23c-1.0-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY

error: Failed dependencies:

oracle-database-preinstall-23c is needed by oracle-database-free-23c-1.0-1.x86_64


Here if you see i dont have the oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm package.


Lets install this misssing package to ensure the preinstall rpm work is done.


[root@node1-example-com Documents]# ls -ltr

total 1717588

-rwxrw-rw-. 1 root root 1758776440 May 10 22:03 oracle-database-free-23c-1.0-1.el8.x86_64.rpm

-rw-------. 1 root root      30688 May 10 22:07 oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm

[root@node1-example-com Documents]# rpm -ivh oracle-database-

oracle-database-free-23c-1.0-1.el8.x86_64.rpm          oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm  

[root@node1-example-com Documents]# rpm -ivh oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm 

warning: oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY

error: Failed dependencies:

compat-openssl10 is needed by oracle-database-preinstall-23c-1.0-0.5.el8.x86_64

glibc-devel is needed by oracle-database-preinstall-23c-1.0-0.5.el8.x86_64

ksh is needed by oracle-database-preinstall-23c-1.0-0.5.el8.x86_64

libnsl is needed by oracle-database-preinstall-23c-1.0-0.5.el8.x86_64

make is needed by oracle-database-preinstall-23c-1.0-0.5.el8.x86_64

sysstat is needed by oracle-database-preinstall-23c-1.0-0.5.el8.x86_64

[root@node1-example-com Documents]# rpm --nodeps -ivh oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm --force

warning: oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY

Verifying...                          ################################# [100%]

Preparing...                          ################################# [100%]

Updating / installing...

   1:oracle-database-preinstall-23c-1.################################# [100%]

[root@node1-example-com Documents]# rpm -ivh oracle-database-free-23c-1.0-1.el8.x86_64.rpm 

warning: oracle-database-free-23c-1.0-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY

Verifying...                          ################################# [100%]

Preparing...                          ################################# [100%]

Updating / installing...

   1:oracle-database-free-23c-1.0-1   ################################# [100%]

root

[INFO] Executing post installation scripts...

[INFO] Oracle home installed successfully and ready to be configured.

To configure Oracle Database Free, optionally modify the parameters in '/etc/sysconfig/oracle-free-23c.conf' and then run '/etc/init.d/oracle-free-23c configure' as root.


Friday, 28 April 2023

High CPU Usage in Oracle Active Data Guard 19c

 Recently i noticed in an Oracle 19.16 database, the standby database server CPU usage went extremely high, we noticed it was the BEQ LOCAL CONNECTION PROCESS is using high cpu, and it was not any application which was running any workload, not even a single application connection was connected to this standby database. Please note this bug was hit even when PDB was mounted while CDB was read only mode. Hence make sure you have the patch 33359773 available for you for the bug id 33359773. You must prove to the Oracle Development that you have hit thig bug. 


Kindly provide the following to the Oracle support for your issue to get the above bug fix and prove that the symptoms match the problem : 


1) alertlog and trace files after you applied the second diag patch.

2)a. Turn on the diagnostics fix

alter system set events '10315 trace name context forever, level 3';

b. Run the test which caused the issue

c. Collect the trace generated

d. Collect AWR repository dump covering the this test period.

e. Collect OSWatcher log covering the this test period.

f. Collect TFA:

$tfactl diagcollect -srdc dbrman

g. Collect the pstack log

watch -n 2 'pstack <target process ospid> >> pstack.txt; echo -e "\n" >> pstack.txt'

h. Turn off the diagnostics fix

alter system set events '10315 trace name context off';


When you run the top command in linux you would see below processes using the high cpu :

So when you ps -ef   grep pid you would see :

 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))


Types of Deadlocks in Oracle Database

 


In a curious case recently, we faced a deadlock in Oracle RAC, so in this post i thought to share the different types of deadlock that can occur in Oracle database.


Deadlock types in Oracle :


Here are some common deadlock types:


1. TX deadlock in Exclusive(X) mode

trace shows:


Global Wait-For-Graph(WFG) at ddTS[0.170] :

BLOCKED 0x8aafb0ec 5 wq 2 cvtops x1 TX 0x320001.0x121c97 [99000-0001-00000002]0

BLOCKER 0x8aafafec 5 wq 1 cvtops x8 TX 0x320001.0x121c97 [9A000-0001-00000002]0

BLOCKED 0x8acb55e4 5 wq 2 cvtops x1 TX 0x430003.0x3843f [9A000-0001-00000002] 0

BLOCKER 0x8acb54e4 5 wq 1 cvtops x8 TX 0x430003.0x3843f [99000-0001-00000002] 0


These values are:

<BLOCKED|BLOCKER> <lockp> <cvt|held mode> <which q> <convert options> <res name - type id1.id2> [deadlock-level-trace] <node> 


Above graph shows the deadlock is related with 2 TX lock in mode 5 (exclusive) which happens on instance 1 (instance# starts from 0)


Above deadlock means two sessions involved in TX-0x320001-0x121c97 and TX-0x430003-0x3843f forms a deadlock, both sessions are from instance 1.


This is a typical application transaction TX enqueue lock, usually caused by SQL commit sequence and high concurrency. To avoid such deadlock, application code and logic need to be modified.


The application and SQL involved in the deadlock can be found in lmd0 or foreground trace (check all instances). Search for: "user session for deadlock lock" section to find out the SQL involved in the deadlock. For example:


user session for deadlock lock 0x8aafb0ec:

...

  current SQL:

  update test set OWNER='APPS' where rownum < 2

 


2. TX deadlock in Share(S) mode

trace shows:


Global Wait-For-Graph(WFG) at ddTS[0.b7] :

BLOCKED 0x2310e8918 3 [0x731000e][0x56268],[TX] [F1000-0001-0000000F] 0

BLOCKER 0x2310e87c8 3 [0x731000e][0x56268],[TX] [19F000-0001-00000011] 0

BLOCKED 0x2310e3c50 3 [0x72a0023][0x530d7],[TX] [19F000-0001-00000011] 0

BLOCKER 0x2310e7e80 3 [0x72a0023][0x530d7],[TX] [F1000-0001-0000000F] 0 


Corresponding to:

<BLOCKED|BLOCKER> <lockp> <cvt|held mode> <res name> <pid|did|txn_id> <node> 

mode 3 is shared lock

The causes for TX deadlock in S mode wait can be:


a. ITL contention, eg: INITRANS setting for the object is too small, it can not handle the number of concurrent transactions.


The solution is to increase INITRANS setting for the object involved in the deadlock using "alter table" or "alter index" command

The SQL involved in the deadlock can be found in lmd0 or client trace. The object involved in the SQL should be checked including table and its associated index.


b. If the object involved is an unique key index, the wait could be caused by uniqueness validation. Application needs to be checked to avoid unique key violation.


c. If the object involved has a bitmap index, then the bitmap index should be dropped to accommodate concurrent DML. Please refer to Document 1496403.1 ORA-60 DEADLOCK DUE TO BITMAP INDEX IN RAC.



3. TM deadlock


trace shows:


Global Wait-For-Graph(WFG) at ddTS[0.1] :

BLOCKED 0x7000003ccbf4798 3 wq 2 cvtops x1 TM 0x1cbde.0x0 [1004-004D-00000003] 0

BLOCKER 0x7000003d0bf9ad8 3 wq 1 cvtops x1 TM 0x1cbde.0x0 [200A-00AC-00000019] 1

BLOCKED 0x7000003d0bfcf88 2 wq 2 cvtops x1 TM 0x1cc77.0x0 [200A-00AC-00000019] 1

BLOCKER 0x7000003cc338e88 2 wq 2 cvtops x1 TM 0x1cc77.0x0 [2006-0063-00000055] 1

BLOCKED 0x7000003cc338e88 3 wq 2 cvtops x1 TM 0x1cc77.0x0 [2006-0063-00000055] 1

BLOCKER 0x7000003c879f9c0 3 wq 1 cvtops x1 TM 0x1cc77.0x0 [2006-0063-00000020] 1

BLOCKED 0x7000003c87978a8 2 wq 2 cvtops x1 TM 0x1cbde.0x0 [2006-0063-00000020] 1

BLOCKER 0x7000003ccbf4798 2 wq 2 cvtops x1 TM 0x1cbde.0x0 [1004-004D-00000003] 0

The object involved here are 0x1cbde and 0x1cc77, convert the hex number to decimal, they are the object_id for the tables involved in above deadlock


The deadlock is usually caused by missing index for foreign key constraint, refer to Document 473124.1 - "Frequent GES: Potential Blocker (Pid=nnnn) On Resource TM-<id1>-<id2>" for more information. Check dba_constraints and dba_index to verify if foreign key index is missing. Also refer to Document 1019527.6 Script to Check for Foreign Key Locking Issues for a Specific User which will generate a report for all problem objects.


The solution is to create index for every foreign key constraint.


4. Single resource deadlock for TX , TM, IV or LB

trace shows:


Single resource deadlock: blocking enqueue which blocks itself, f 1

Granted global enqueue 0xd078cec0

...

resname :[0x2001f][0x1a96c3],[TX]

or

resname :[0x00001432][0x0],[TM]

or

resname : [0xbb7cc5db][0x82d0d4b5],[IV]

or

resname : [0x5e582fb9][0xa216c7af],[LB]


a. For single resource deadlock on TX enqueue, often it is caused by using autonomous transaction in stored procedure or PL/SQL. It is a known issue that the use of autonomous transactions is vulnerable to deadlocks. Please check out Oracle® Database Concepts  Overview of Autonomous Transactions for detail explanation. Since AUTONOMOUS transaction has been used in the stored procedure, the system would consider any DML statement under this transaction as a separate one (commit/rollback won't affect the parent), and this would cause conflict if the same row is involved in the parent transaction (INSERT, UPDATE or DELETE), and hence deadlock is reported rightly. Usually the SQL involved in the deadlock is called from a stored procedure or PL/SQL with the following line:


PRAGMA AUTONOMOUS_TRANSACTION;

To avoid such deadlock, please remove the autonomous transaction in the application code.


b. If there is no autonomous_transaction involved, please check out Document 6145177.8, it can also be caused by Bug 6145177 - Single resource deadlock with a zero DID


c. For single resource deadlock on TM enqueue, missing foreign key index is often the cause, please check case 3 for the solution.


d. For single resource deadlock type IV (Instance Validation), refer to Document 973178.1, as mentioned in Bug 8843816, this message can be ignored. Bug 8843816 has been fixed in 11.1.


e. For single resource deadlock on LB (Library Cache Lock) with DID 0, if it is on external table disable stats on external table as below:  alter session set "_px_external_table_default_stats" = false; Reference Bug 21204478


5. LB deadlock

Global Wait-For-Graph(WFG) at ddTS[0.390] :

BLOCKED 0x3bc3e1b48 5 wq 2 cvtops x0 [0xd2703c03][0x545a14a5],[LB] [7B000-0002-00006C9D] 1

BLOCKER 0x3bc2efad0 5 wq 1 cvtops x0 [0xd2703c03][0x545a14a5],[LB] [48000-0001-000069FE] 0

BLOCKED 0x3bc2ed1c0 3 wq 2 cvtops x0 [0x415d0160][0xca28e8cf],[LB] [48000-0001-000069FE] 0

BLOCKER 0x3bc2dc648 3 wq 2 cvtops x0 [0x415d0160][0xca28e8cf],[LB] [34000-0001-0000095E] 0

BLOCKED 0x3bc2dc648 5 wq 2 cvtops x0 [0x415d0160][0xca28e8cf],[LB] [34000-0001-0000095E] 0

BLOCKER 0x3bc2dbbb0 5 wq 1 cvtops x0 [0x415d0160][0xca28e8cf],[LB] [76000-0002-000074D4] 1

BLOCKED 0x3bc2ef830 3 wq 2 cvtops x0 [0xd2703c03][0x545a14a5],[LB] [76000-0002-000074D4] 1

BLOCKER 0x3bc3e1b48 3 wq 2 cvtops x0 [0xd2703c03][0x545a14a5],[LB] [7B000-0002-00006C9D] 1

LB lock type refers to library cache lock. This type of deadlock is usually caused by a bug. 


For example: Bug 6475688  Concurrent rewrite and on-commit refresh can deadlock (library cache pin <--> lock) Document 6475688.8

The bug has been fixed in 11.1.0.7 and 11.2. Please apply patch accordingly.


6. Known Issues

For other deadlock type or known issues related to dead lock, refer to Document 554567.1 Summary Of Bugs Which Could Cause Deadlock In RAC Environment


7. Further Diagnosis

Please collect the following information for further diagnosis:


a. alert log lmd0, and trace mentioned in the alert log from all instances.

b. set the following event to collect systemstate dump ONLY if the information in trace files are insufficient:


alter system set events '60 trace name systemstate level 258';

It will cause a systemstate dump to be generated whenever a deadlock is reported. If there are constant deadlocks, it could cause a lot of trace files being generated, monitor the system carefully.


To turn off the trace:


alter system set events '60 trace name context off';


8. Deadlock Parser Tool (Enterprise Manager)

EM 12c, EM 13c: Using The Deadlock Parser Tool For Gathering EM Repository Deadlock Information Document:2222769.1

How to open a database from read write mode to mount status

 SQL> select name,open_mode from v$database;


NAME      OPEN_MODE

--------- --------------------

ORCL      READ WRITE


SQL> alter database mount;

alter database mount

*

ERROR at line 1:

ORA-01100: database already mounted


# So here we get the error database is already mounted, in this case we need to ensure the database is shutdown first and then only we can mount the database.



SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.


# So lets see how we can do it

SQL> startup mount

ORACLE instance started.

Total System Global Area 1073740680 bytes
Fixed Size                  9694088 bytes
Variable Size             306184192 bytes
Database Buffers          754974720 bytes
Redo Buffers                2887680 bytes
Database mounted.
SQL> SQL>

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORCL      MOUNTED

# With this we know how we can mount the database from open state.