SlideShare une entreprise Scribd logo
1  sur  65
 
PASS Community Summit - Seattle November 18-22, 2002 S231/S348 - Resolving Deadlocks in SQL Server 2000 Ron Talmage - Prospice, LLC
Agenda:  Troubleshooting Deadlocks in SQL Server 2000 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Troubleshooting Deadlocks in SQL Server 2000 ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],Deadlocking Defined
Lock-Based Deadlocking Structure GRANT T3 Request(WAIT on Tran1) T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Request (WAIT on Tran2) T4 Blocked GRANT T2 Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
Deadlocking Illustrated Thread 1 Thread 2 Grant Wait Blocked request Resource Resource
SQL Server Resource Waits ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Deadlocks Involving Locks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Deadlocking is more than Blocking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How SQL Server handles a Deadlock ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Error 1205 Notes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL Server Deadlocking Factors ,[object Object],[object Object],[object Object],[object Object]
1. Lock Modes Used with bulk copy into a table with either TABLOCK hint or table lock option is set BU Bulk Update Have update lock with intent to acquire exclusive lock at a finer level UIX Update Intent Exclusive Have shared lock with intent to acquire exclusive lock at a finer level SIX Shared Intent Exclusive Have shared lock with intent to acquire update lock at a finer level SIU Shared Intent Update Have or intend to request exclusive lock(s) at a finer level IX Intent Exclusive Have or intend to request update lock(s) at a finer level IU Intent Update Have or intend to request shared lock(s) at a finer level IS Intent Shared Used for writing (insert, update, delete) X Exclusive Used to evaluate prior to writing (may become exclusive) U Update Used for reading (read lock) S Shared Used for DDL operations (ALTER or DROP) on a table schema Sch-M Schema Modification Used when compiling queries Sch-S Schema-Stability Description Abbreviation Lock Mode
Lock Compatibility Matrix (default isolation level) Lock Mode Already Granted BU Sch-M Sch-S X SIX IX U S IS Lock Mode Requested No No Yes No Yes Yes Yes Yes Yes IS No No Yes No No No Yes Yes Yes S No No Yes No No No No Yes Yes U No No Yes No No Yes No No Yes IX No No Yes No No No No No Yes SIX No No Yes No No No No No No X Yes No Yes No No No No No No BU No No No No No No No No No Sch-M Yes No Yes Yes Yes Yes Yes Yes Yes Sch-S
2. Transaction Timing ,[object Object],[object Object],[object Object]
3. Order of Lock Requests ,[object Object],[object Object]
4. Isolation Level ,[object Object],[object Object],[object Object],[object Object]
Isolation Level and Lock Accumulation Held until end of transaction Held until end of transaction unless promoted to exclusive or released  Held until data read and processed Read Un-committed Held until end of transaction Held until end of transaction unless promoted to exclusive Held until end of transaction Repeatable Read Held until end of transaction Held until end of transaction Exclusive Held until end of transaction unless promoted to exclusive Held until end of transaction unless promoted to exclusive or released Update Held until end of transaction Held until data read and processed Shared Serializable Read Committed Lock Mode
Troubleshooting Deadlocks in SQL Server 2000 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Types of Lock Deadlocks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
Single-Resource  Deadlock Illustrated  Resource Thread 1 Thread 2 Grant Wait Blocked request
Single-Resource Deadlock   Select *  From Authors With (HOLDLOCK)  Where au_id = '172-32-1176' T3 GRANT Update Authors  Set contract = 1  Where au_id = '172-32-1176' T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Update Authors  Set contract = 0  Where au_id = '172-32-1176' T4 Blocked Select *  From Authors With (HOLDLOCK)  Where au_id = '172-32-1176' T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
Single-Resource Deadlock Notes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
2. Multi-Resource Deadlocks  Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
MR  Deadlock Illustrated Res 1 Thread 1 Thread 2 Res 2 Grant Wait Blocked request
X-only MR Deadlock Variation ,[object Object],[object Object],[object Object],[object Object]
X-only MR Deadlock Update Titles  Set ytd_sales = 0  Where title_id = ‘BU1032' T3 GRANT Update Authors  Set contract = 0  Where au_id = '172-32-1176' T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Update Titles  Set ytd_sales = 0  Where title_id = ‘BU1032' T4 Blocked Update Authors  Set contract = 0  Where au_id = '172-32-1176' T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
X-only MR Deadlock Notes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mixed X-S MR Deadlock Variation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mixed X-S MR Example #1 Update Titles  Set ytd_sales = 0  Where title_id = ‘BU1032' T3 GRANT Select * From Authors  Where au_id = '172-32-1176' T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Select * From Titles  Where title_id = ‘BU1032' T4 Blocked Update Authors  Set contract = 0  Where au_id = '172-32-1176' T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
Mixed X-S MR Example #2 Insert Authors Values  ('111-11-1112', 'test2', '', '', '', '', '', '11111', 0) T3 GRANT Select * From Authors  T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Select *  From Authors  T4 Blocked Insert Authors Values  ('111-11-1111', 'test1', '', '', '', '', '', '11111', 0) T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
Mixed X-S MR Deadlock Notes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Troubleshooting Deadlocks in SQL Server 2000 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Gathering Deadlock Information ,[object Object],[object Object],[object Object],[object Object]
1. Use the Deadlocks/sec Sysmon (Perfmon) counter ,[object Object],[object Object]
Adding the Deadlock Counter
2. Use the 1204 Trace Flag ,[object Object],[object Object],[object Object],[object Object],[object Object]
Retrieving 1204 Output ,[object Object],[object Object],[object Object],[object Object]
Sample Trace Flag 1204 Output ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Locked resource (leaf node of clustered key, I.e. row) Spid owning the lock Current input buffer Type of lock granted Requesting spid and lock type requested Deadlock victim spid Hash of key value
Interpreting Trace Flag 1204 Output ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Trace Flag 1204 Output Notes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
3. Use SQL Trace with Profiler ,[object Object],[object Object],[object Object],[object Object],[object Object]
Configuring SQL Trace/Profiler ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL Trace and SP2 ,[object Object],[object Object]
Viewing Deadlocks in Profiler Deadlock spids now cross-referenced in SP2
SQL Trace Output Notes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Troubleshooting Deadlocks in SQL Server 2000 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Isolating the Cause ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Steps for Reproducing a Complex Deadlock ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Extracting a Transaction History
Reproducing the Deadlock
Observing Locks ,[object Object],[object Object],[object Object],[object Object],[object Object]
Identifying the query
Identifying the locks KEY: 7:1977058079:1 (f600d547433a) (from trace flag 1204 output)
Troubleshooting Deadlocks in SQL Server 2000 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Resolution Techniques  ,[object Object],[object Object],[object Object],[object Object]
1. Remove incompatible lock requests ,[object Object],[object Object],[object Object],[object Object],[object Object]
2. Change the timing of transactions ,[object Object],[object Object],[object Object],[object Object]
3. Change the order of resource requests ,[object Object],[object Object]
4. Change the Isolation Level ,[object Object],[object Object],[object Object],[object Object],[object Object]
Additional Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank you! Thank you for attending this session and PASS Community Summit - Seattle! Please help us improve the quality of our conference by completing your session evaluation form.  Completed evaluation forms may be given to the room monitor as you exit or to staff at the registration desk.
Produced by In association with

Contenu connexe

Similaire à Troubleshooting Deadlocks in SQL Server 2000

Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12
Syed Asrarali
 

Similaire à Troubleshooting Deadlocks in SQL Server 2000 (20)

The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
The nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levelsThe nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levels
 
The nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levelsThe nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levels
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
lock, block & two smoking barrels
lock, block & two smoking barrelslock, block & two smoking barrels
lock, block & two smoking barrels
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
 
Locking And Concurrency
Locking And ConcurrencyLocking And Concurrency
Locking And Concurrency
 
concurrency control
concurrency controlconcurrency control
concurrency control
 
Managing Memory & Locks - Series 2 Transactions & Lock management
Managing  Memory & Locks - Series 2 Transactions & Lock managementManaging  Memory & Locks - Series 2 Transactions & Lock management
Managing Memory & Locks - Series 2 Transactions & Lock management
 
Look inside the locking mechanism
Look inside the locking mechanismLook inside the locking mechanism
Look inside the locking mechanism
 
Variations Of Two Phase Locking
Variations Of Two Phase LockingVariations Of Two Phase Locking
Variations Of Two Phase Locking
 
The Nightmare of Locking, Blocking and Isolation Levels
The Nightmare of Locking, Blocking and Isolation LevelsThe Nightmare of Locking, Blocking and Isolation Levels
The Nightmare of Locking, Blocking and Isolation Levels
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
Locking and concurrency
Locking and concurrencyLocking and concurrency
Locking and concurrency
 
SQL Server Blocking Analysis
SQL Server Blocking AnalysisSQL Server Blocking Analysis
SQL Server Blocking Analysis
 
Database security
Database securityDatabase security
Database security
 

Plus de elliando dias

Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

Plus de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Troubleshooting Deadlocks in SQL Server 2000

  • 1.  
  • 2. PASS Community Summit - Seattle November 18-22, 2002 S231/S348 - Resolving Deadlocks in SQL Server 2000 Ron Talmage - Prospice, LLC
  • 3.
  • 4.
  • 5.
  • 6. Lock-Based Deadlocking Structure GRANT T3 Request(WAIT on Tran1) T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Request (WAIT on Tran2) T4 Blocked GRANT T2 Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
  • 7. Deadlocking Illustrated Thread 1 Thread 2 Grant Wait Blocked request Resource Resource
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. 1. Lock Modes Used with bulk copy into a table with either TABLOCK hint or table lock option is set BU Bulk Update Have update lock with intent to acquire exclusive lock at a finer level UIX Update Intent Exclusive Have shared lock with intent to acquire exclusive lock at a finer level SIX Shared Intent Exclusive Have shared lock with intent to acquire update lock at a finer level SIU Shared Intent Update Have or intend to request exclusive lock(s) at a finer level IX Intent Exclusive Have or intend to request update lock(s) at a finer level IU Intent Update Have or intend to request shared lock(s) at a finer level IS Intent Shared Used for writing (insert, update, delete) X Exclusive Used to evaluate prior to writing (may become exclusive) U Update Used for reading (read lock) S Shared Used for DDL operations (ALTER or DROP) on a table schema Sch-M Schema Modification Used when compiling queries Sch-S Schema-Stability Description Abbreviation Lock Mode
  • 15. Lock Compatibility Matrix (default isolation level) Lock Mode Already Granted BU Sch-M Sch-S X SIX IX U S IS Lock Mode Requested No No Yes No Yes Yes Yes Yes Yes IS No No Yes No No No Yes Yes Yes S No No Yes No No No No Yes Yes U No No Yes No No Yes No No Yes IX No No Yes No No No No No Yes SIX No No Yes No No No No No No X Yes No Yes No No No No No No BU No No No No No No No No No Sch-M Yes No Yes Yes Yes Yes Yes Yes Yes Sch-S
  • 16.
  • 17.
  • 18.
  • 19. Isolation Level and Lock Accumulation Held until end of transaction Held until end of transaction unless promoted to exclusive or released Held until data read and processed Read Un-committed Held until end of transaction Held until end of transaction unless promoted to exclusive Held until end of transaction Repeatable Read Held until end of transaction Held until end of transaction Exclusive Held until end of transaction unless promoted to exclusive Held until end of transaction unless promoted to exclusive or released Update Held until end of transaction Held until data read and processed Shared Serializable Read Committed Lock Mode
  • 20.
  • 21.
  • 22.
  • 23. Single-Resource Deadlock Illustrated Resource Thread 1 Thread 2 Grant Wait Blocked request
  • 24. Single-Resource Deadlock Select * From Authors With (HOLDLOCK) Where au_id = '172-32-1176' T3 GRANT Update Authors Set contract = 1 Where au_id = '172-32-1176' T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Update Authors Set contract = 0 Where au_id = '172-32-1176' T4 Blocked Select * From Authors With (HOLDLOCK) Where au_id = '172-32-1176' T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
  • 25.
  • 26.
  • 27. MR Deadlock Illustrated Res 1 Thread 1 Thread 2 Res 2 Grant Wait Blocked request
  • 28.
  • 29. X-only MR Deadlock Update Titles Set ytd_sales = 0 Where title_id = ‘BU1032' T3 GRANT Update Authors Set contract = 0 Where au_id = '172-32-1176' T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Update Titles Set ytd_sales = 0 Where title_id = ‘BU1032' T4 Blocked Update Authors Set contract = 0 Where au_id = '172-32-1176' T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
  • 30.
  • 31.
  • 32. Mixed X-S MR Example #1 Update Titles Set ytd_sales = 0 Where title_id = ‘BU1032' T3 GRANT Select * From Authors Where au_id = '172-32-1176' T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Select * From Titles Where title_id = ‘BU1032' T4 Blocked Update Authors Set contract = 0 Where au_id = '172-32-1176' T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
  • 33. Mixed X-S MR Example #2 Insert Authors Values ('111-11-1112', 'test2', '', '', '', '', '', '11111', 0) T3 GRANT Select * From Authors T5 Blocked (blocking removed) Deadlock Victim T6 Commit T7 Select * From Authors T4 Blocked Insert Authors Values ('111-11-1111', 'test1', '', '', '', '', '', '11111', 0) T2 GRANT Begin Tran Begin Tran T1 Tran 2 Tran 1 Time
  • 34.
  • 35.
  • 36.
  • 37.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47. Viewing Deadlocks in Profiler Deadlock spids now cross-referenced in SP2
  • 48.
  • 49.
  • 50.
  • 51.
  • 54.
  • 56. Identifying the locks KEY: 7:1977058079:1 (f600d547433a) (from trace flag 1204 output)
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64. Thank you! Thank you for attending this session and PASS Community Summit - Seattle! Please help us improve the quality of our conference by completing your session evaluation form. Completed evaluation forms may be given to the room monitor as you exit or to staff at the registration desk.
  • 65. Produced by In association with