SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
Oracle Diagnostics
Hemant K Chitale
Hemant K Chitale
• whoami ?
• Oracle 5 to Oracle 10gR2 : DOS, Xenix,8
flavours of Unix, Linux, Windows
• Financial Services, Govt/Not-for-Profit, ERP,
Custom
• Production Support, Consulting, Development
• A DBA, not a Developer
• Product Specialist, Standard Chartered Bank
• My Oracle Blog http://hemantoracledba.blogspot.com
Locks and Lock Trees
• Row Locks are Enqueues
• They serialise access to rows
• A transaction may hold Row Locks on multiple
rows – this is represented as a single entry in
V$TRANSACTION but single or multiple entries
in the ITL slots in various table / index blocks
• ITLs allow different transactions to lock different
rows in the same block concurrently.
• Lock Trees are multiple sessions waiting “in
order”, with potentially more than one session
waiting on the same row lock
A Lock Tree :
Script “utllockt.sql” (in $ORACLE_HOME/rdbms/admin) can provide a tree-like
diagram.
* This script prints the sessions in the system that are waiting for
* locks, and the locks that they are waiting for. The printout is tree
* structured. If a sessionid is printed immediately below and to the right
* of another session, then it is waiting for that session. The session ids
* printed at the left hand side of the page are the ones that everyone is
* waiting for.
*
* For example, in the following printout session 9 is waiting for
* session 8, 7 is waiting for 9, and 10 is waiting for 9.
*
* WAITING_SESSION TYPE MODE REQUESTED MODE HELD LOCK ID1 LOCK ID2
* ----------------- ---- ----------------- ----------------- -------- --------
* 8 NONE None None 0 0
* 9 TX Share (S) Exclusive (X) 65547 16
* 7 RW Exclusive (X) S/Row-X (SSX) 33554440 2
* 10 RW Exclusive (X) S/Row-X (SSX) 33554440 2
*
* The lock information to the right of the session id describes the lock
* that the session is waiting for (not the lock it is holding).
The script can be enhanced to provide more session information. The script
uses DDLs to drop and create temp tables – so another enhancement would
be to have those tables created in advance as GTTs and only populated and
queried by the script
Here is a query to list Lock Holders and Waiters:
select s.blocking_session, to_number(s.sid) Waiting_Session, s.event, s.seconds_in_wait,
p.pid,
p.spid "ServerPID", s.process "ClientPID",
s.username, s.program, s.machine, s.osuser, s.sql_id,
substr(sq.sql_text,1,75) SQL
from v$sql sq, v$session s, v$process p
where s.event like 'enq: TX%'
and s.paddr=p.addr
and s.sql_address=sq.address
and s.sql_hash_value=sq.hash_value
and s.sql_id=sq.sql_id
and s.sql_child_number=sq.child_number
union all
select s.blocking_session, to_number(s.sid) Waiting_Session, s.event, s.seconds_in_wait,
p.pid,
p.spid "ServerPID", s.process "ClientPID",
s.username, s.program, s.machine, s.osuser, s.sql_id,
substr(sq.sql_text,1,75) SQL
from v$sql sq, v$session s, v$process p
where s.sid in (select distinct blocking_session from v$session where event like 'enq:
TX%')
and s.paddr=p.addr
and s.sql_address=sq.address(+)
and s.sql_hash_value=sq.hash_value(+)
and s.sql_id=sq.sql_id(+)
and s.sql_child_number=sq.child_number(+)
order by 1 nulls first, 2
/
This method does NOT require any temporary tables !
Example 1 :
Two separate sessions attempting to update the same row :
SQL> connect ABC_DBA/ABC_DBA_123
Connected.
SQL> update hemant.test_row_lock set content = 'Another' where
pk=1;
1 row updated.
SQL>
SQL> connect hemant/hemant
Connected.
SQL> update test_row_lock set content = 'First' where pk=1;
….. now waiting …..
BLOCKING_SESSION WAITING_SESSION EVENT
SECONDS_IN_WAIT PID
---------------- --------------- --------------------------------------------------------
-------- --------------- ----------
ServerPID ClientPID USERNAME PROGRAM
------------------------ ------------------------ ------------------------------ --------
----------------------------------------
MACHINE OSUSER
SQL_ID
---------------------------------------------------------------- ------------------------
------ -------------
SQL
-----------------------------------------------------------------------------------------
-------------------------------------------
17 SQL*Net message from client
82 27
13788 13770 ABC_DBA
sqlplus@localhost.localdomain (TNS V1-V3)
localhost.localdomain oracle
17 26 enq: TX - row lock contention
52 19
13791 3449 HEMANT
sqlplus@localhost.localdomain (TNS V1-V3)
localhost.localdomain oracle
fuwn3bnuh2axg
update test_row_lock set content = 'First' where pk=1
SQL>
Findings for Ex. 1 :
Session 17 (ABC_DBA) has no „BLOCKING_SESSION‟. It isn‟t waiting. It is
the Blocker itself.
Session 26 (HEMANT) as a „WAITING_SESSION‟ presents Session 17 as
being the „BLOCKING_SESSION‟.
Session 26 is waiting on a Row Lock while currently running “update
test_row_lock set content = 'First' where pk=1”
Example 2 :
Table Definition :
SQL> create table test_unique_insert_row_lock
(col_1 number , col_2 varchar2(5));
Table created.
SQL> create unique index t_u_i_r_l_unq_ndx on
test_unique_insert_row_lock (col_1);
Index created.
SQL>
Example 2 (contd):
SQL> connect ABC_DBA/ABC_DBA_123
Connected.
SQL> insert into hemant.test_unique_insert_row_lock values
(1, 'Sn.1');
1 row created.
SQL>
SQL> connect hemant/hemant
Connected.
SQL> insert into hemant.test_unique_insert_row_lock values
(1,'Sn.2');
….. now waiting …..
BLOCKING_SESSION WAITING_SESSION EVENT
SECONDS_IN_WAIT PID
---------------- --------------- --------------------------------------------------
-------------- --------------- ----------
ServerPID ClientPID USERNAME
PROGRAM
------------------------ ------------------------ ------------------------------ --
----------------------------------------------
MACHINE OSUSER
SQL_ID
---------------------------------------------------------------- ------------------
------------ -------------
SQL
---------------------------------------------------------------------------
1 SQL*Net message from client
115 22
13007 12813 ABC_DBA
sqlplus@localhost.localdomain (TNS V1-V3)
localhost.localdomain oracle
1 36 enq: TX - row lock contention
80 25
13009 12971 HEMANT
sqlplus@localhost.localdomain (TNS V1-V3)
localhost.localdomain oracle
166dv336yhxua
insert into hemant.test_unique_insert_row_lock values (1,'Sn.2')
2 rows selected.
SQL>
Findings for Ex 2 :
Session 1 (ABC_DBA) has no blocker
Session 36 (HEMANT) is waiting on Session 1
So, even a Duplicate Value on INSERT actually “waits” on the INSERT that
has not committed. The row inserted by ABC_DBA is not visible to
HEMANT (because ABC_DBA has not yet committed) but HEMANT‟s
INSERT waits on the Row Lock !

Weitere ähnliche Inhalte

Was ist angesagt?

SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)Bernardo Damele A. G.
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesAlex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
How to export import a mysql database via ssh in aws lightsail wordpress rizw...
How to export import a mysql database via ssh in aws lightsail wordpress rizw...How to export import a mysql database via ssh in aws lightsail wordpress rizw...
How to export import a mysql database via ssh in aws lightsail wordpress rizw...AlexRobert25
 
Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema PluginsMark Leith
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Bernardo Damele A. G.
 
Barun_Practical_and_Efficient_SQL_Performance_Tuning
Barun_Practical_and_Efficient_SQL_Performance_TuningBarun_Practical_and_Efficient_SQL_Performance_Tuning
Barun_Practical_and_Efficient_SQL_Performance_TuningVlado Barun
 
Introduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQLIntroduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQLFrans Jongma
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptFramgia Vietnam
 
Database security
Database securityDatabase security
Database securityJaved Khan
 
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015Alex Zaballa
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmapHerman Duarte
 
Basic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationBasic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationN/A
 
Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)Bernardo Damele A. G.
 
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...Alex Zaballa
 

Was ist angesagt? (20)

SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
 
Firebird
FirebirdFirebird
Firebird
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Sql Injection 0wning Enterprise
Sql Injection 0wning EnterpriseSql Injection 0wning Enterprise
Sql Injection 0wning Enterprise
 
Usertracing
UsertracingUsertracing
Usertracing
 
How to export import a mysql database via ssh in aws lightsail wordpress rizw...
How to export import a mysql database via ssh in aws lightsail wordpress rizw...How to export import a mysql database via ssh in aws lightsail wordpress rizw...
How to export import a mysql database via ssh in aws lightsail wordpress rizw...
 
Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema Plugins
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
 
Barun_Practical_and_Efficient_SQL_Performance_Tuning
Barun_Practical_and_Efficient_SQL_Performance_TuningBarun_Practical_and_Efficient_SQL_Performance_Tuning
Barun_Practical_and_Efficient_SQL_Performance_Tuning
 
Pl sql-ch2
Pl sql-ch2Pl sql-ch2
Pl sql-ch2
 
Introduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQLIntroduction to embedded sql for NonStop SQL
Introduction to embedded sql for NonStop SQL
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
Database security
Database securityDatabase security
Database security
 
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
 
Basic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationBasic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition Presentation
 
Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)
 
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
 

Ähnlich wie Oracle Diagnostics : Locks and Lock Trees

11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01Karam Abuataya
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11gfcamachob
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsJohn Kanagaraj
 
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleUnderstanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleGuatemala User Group
 
Odv oracle customer_demo
Odv oracle customer_demoOdv oracle customer_demo
Odv oracle customer_demoViaggio Italia
 
Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)Hemant K Chitale
 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP ConferenceDave Stokes
 
Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!Stefan Oehrli
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersConnor McDonald
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part IIIAlkin Tezuysal
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 MinutesSveta Smirnova
 
My First 100 days with an Exadata (PPT)
My First 100 days with an Exadata (PPT)My First 100 days with an Exadata (PPT)
My First 100 days with an Exadata (PPT)Gustavo Rene Antunez
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksKyle Hailey
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)akirahiguchi
 
Being HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeBeing HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeAman Kohli
 

Ähnlich wie Oracle Diagnostics : Locks and Lock Trees (20)

11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
 
MySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB StatusMySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB Status
 
Rmoug ashmaster
Rmoug ashmasterRmoug ashmaster
Rmoug ashmaster
 
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleUnderstanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
 
Odv oracle customer_demo
Odv oracle customer_demoOdv oracle customer_demo
Odv oracle customer_demo
 
Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)Oracle Diagnostics : Explain Plans (Simple)
Oracle Diagnostics : Explain Plans (Simple)
 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
 
Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!Security Best Practice: Oracle passwords, but secure!
Security Best Practice: Oracle passwords, but secure!
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part III
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 
My First 100 days with an Exadata (PPT)
My First 100 days with an Exadata (PPT)My First 100 days with an Exadata (PPT)
My First 100 days with an Exadata (PPT)
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction Locks
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)
 
Being HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeBeing HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on Purpose
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 

Mehr von Hemant K Chitale

Oracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and EnqueuesOracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and EnqueuesHemant K Chitale
 
Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Hemant K Chitale
 
Partitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- ArticlePartitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- ArticleHemant K Chitale
 
Oracle database performance diagnostics - before your begin
Oracle database performance diagnostics  - before your beginOracle database performance diagnostics  - before your begin
Oracle database performance diagnostics - before your beginHemant K Chitale
 
Partitioning tables and indexing them
Partitioning tables and indexing them Partitioning tables and indexing them
Partitioning tables and indexing them Hemant K Chitale
 

Mehr von Hemant K Chitale (7)

SQL Tracing
SQL TracingSQL Tracing
SQL Tracing
 
Oracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and EnqueuesOracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and Enqueues
 
Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1
 
Partitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- ArticlePartitioning Tables and Indexing Them --- Article
Partitioning Tables and Indexing Them --- Article
 
Oracle database performance diagnostics - before your begin
Oracle database performance diagnostics  - before your beginOracle database performance diagnostics  - before your begin
Oracle database performance diagnostics - before your begin
 
The role of the dba
The role of the dba The role of the dba
The role of the dba
 
Partitioning tables and indexing them
Partitioning tables and indexing them Partitioning tables and indexing them
Partitioning tables and indexing them
 

Kürzlich hochgeladen

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Kürzlich hochgeladen (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Oracle Diagnostics : Locks and Lock Trees

  • 2. Hemant K Chitale • whoami ? • Oracle 5 to Oracle 10gR2 : DOS, Xenix,8 flavours of Unix, Linux, Windows • Financial Services, Govt/Not-for-Profit, ERP, Custom • Production Support, Consulting, Development • A DBA, not a Developer • Product Specialist, Standard Chartered Bank • My Oracle Blog http://hemantoracledba.blogspot.com
  • 3. Locks and Lock Trees • Row Locks are Enqueues • They serialise access to rows • A transaction may hold Row Locks on multiple rows – this is represented as a single entry in V$TRANSACTION but single or multiple entries in the ITL slots in various table / index blocks • ITLs allow different transactions to lock different rows in the same block concurrently. • Lock Trees are multiple sessions waiting “in order”, with potentially more than one session waiting on the same row lock
  • 4. A Lock Tree : Script “utllockt.sql” (in $ORACLE_HOME/rdbms/admin) can provide a tree-like diagram. * This script prints the sessions in the system that are waiting for * locks, and the locks that they are waiting for. The printout is tree * structured. If a sessionid is printed immediately below and to the right * of another session, then it is waiting for that session. The session ids * printed at the left hand side of the page are the ones that everyone is * waiting for. * * For example, in the following printout session 9 is waiting for * session 8, 7 is waiting for 9, and 10 is waiting for 9. * * WAITING_SESSION TYPE MODE REQUESTED MODE HELD LOCK ID1 LOCK ID2 * ----------------- ---- ----------------- ----------------- -------- -------- * 8 NONE None None 0 0 * 9 TX Share (S) Exclusive (X) 65547 16 * 7 RW Exclusive (X) S/Row-X (SSX) 33554440 2 * 10 RW Exclusive (X) S/Row-X (SSX) 33554440 2 * * The lock information to the right of the session id describes the lock * that the session is waiting for (not the lock it is holding). The script can be enhanced to provide more session information. The script uses DDLs to drop and create temp tables – so another enhancement would be to have those tables created in advance as GTTs and only populated and queried by the script
  • 5. Here is a query to list Lock Holders and Waiters: select s.blocking_session, to_number(s.sid) Waiting_Session, s.event, s.seconds_in_wait, p.pid, p.spid "ServerPID", s.process "ClientPID", s.username, s.program, s.machine, s.osuser, s.sql_id, substr(sq.sql_text,1,75) SQL from v$sql sq, v$session s, v$process p where s.event like 'enq: TX%' and s.paddr=p.addr and s.sql_address=sq.address and s.sql_hash_value=sq.hash_value and s.sql_id=sq.sql_id and s.sql_child_number=sq.child_number union all select s.blocking_session, to_number(s.sid) Waiting_Session, s.event, s.seconds_in_wait, p.pid, p.spid "ServerPID", s.process "ClientPID", s.username, s.program, s.machine, s.osuser, s.sql_id, substr(sq.sql_text,1,75) SQL from v$sql sq, v$session s, v$process p where s.sid in (select distinct blocking_session from v$session where event like 'enq: TX%') and s.paddr=p.addr and s.sql_address=sq.address(+) and s.sql_hash_value=sq.hash_value(+) and s.sql_id=sq.sql_id(+) and s.sql_child_number=sq.child_number(+) order by 1 nulls first, 2 / This method does NOT require any temporary tables !
  • 6. Example 1 : Two separate sessions attempting to update the same row : SQL> connect ABC_DBA/ABC_DBA_123 Connected. SQL> update hemant.test_row_lock set content = 'Another' where pk=1; 1 row updated. SQL> SQL> connect hemant/hemant Connected. SQL> update test_row_lock set content = 'First' where pk=1; ….. now waiting …..
  • 7. BLOCKING_SESSION WAITING_SESSION EVENT SECONDS_IN_WAIT PID ---------------- --------------- -------------------------------------------------------- -------- --------------- ---------- ServerPID ClientPID USERNAME PROGRAM ------------------------ ------------------------ ------------------------------ -------- ---------------------------------------- MACHINE OSUSER SQL_ID ---------------------------------------------------------------- ------------------------ ------ ------------- SQL ----------------------------------------------------------------------------------------- ------------------------------------------- 17 SQL*Net message from client 82 27 13788 13770 ABC_DBA sqlplus@localhost.localdomain (TNS V1-V3) localhost.localdomain oracle 17 26 enq: TX - row lock contention 52 19 13791 3449 HEMANT sqlplus@localhost.localdomain (TNS V1-V3) localhost.localdomain oracle fuwn3bnuh2axg update test_row_lock set content = 'First' where pk=1 SQL>
  • 8. Findings for Ex. 1 : Session 17 (ABC_DBA) has no „BLOCKING_SESSION‟. It isn‟t waiting. It is the Blocker itself. Session 26 (HEMANT) as a „WAITING_SESSION‟ presents Session 17 as being the „BLOCKING_SESSION‟. Session 26 is waiting on a Row Lock while currently running “update test_row_lock set content = 'First' where pk=1”
  • 9. Example 2 : Table Definition : SQL> create table test_unique_insert_row_lock (col_1 number , col_2 varchar2(5)); Table created. SQL> create unique index t_u_i_r_l_unq_ndx on test_unique_insert_row_lock (col_1); Index created. SQL>
  • 10. Example 2 (contd): SQL> connect ABC_DBA/ABC_DBA_123 Connected. SQL> insert into hemant.test_unique_insert_row_lock values (1, 'Sn.1'); 1 row created. SQL> SQL> connect hemant/hemant Connected. SQL> insert into hemant.test_unique_insert_row_lock values (1,'Sn.2'); ….. now waiting …..
  • 11. BLOCKING_SESSION WAITING_SESSION EVENT SECONDS_IN_WAIT PID ---------------- --------------- -------------------------------------------------- -------------- --------------- ---------- ServerPID ClientPID USERNAME PROGRAM ------------------------ ------------------------ ------------------------------ -- ---------------------------------------------- MACHINE OSUSER SQL_ID ---------------------------------------------------------------- ------------------ ------------ ------------- SQL --------------------------------------------------------------------------- 1 SQL*Net message from client 115 22 13007 12813 ABC_DBA sqlplus@localhost.localdomain (TNS V1-V3) localhost.localdomain oracle 1 36 enq: TX - row lock contention 80 25 13009 12971 HEMANT sqlplus@localhost.localdomain (TNS V1-V3) localhost.localdomain oracle 166dv336yhxua insert into hemant.test_unique_insert_row_lock values (1,'Sn.2') 2 rows selected. SQL>
  • 12. Findings for Ex 2 : Session 1 (ABC_DBA) has no blocker Session 36 (HEMANT) is waiting on Session 1 So, even a Duplicate Value on INSERT actually “waits” on the INSERT that has not committed. The row inserted by ABC_DBA is not visible to HEMANT (because ABC_DBA has not yet committed) but HEMANT‟s INSERT waits on the Row Lock !