SlideShare a Scribd company logo
1
Shah Faisal Ali
BACKGROUND
• Locks are used by SQL Server DB engine to protect a
resource from modification by concurrent
transactions simultaneously.
• Among many locks used by SQL Server Update lock
is one of the least understood locks.
• This lock is used by SQL Server Database Engine to
prevent a kind of deadlock which would have been
possible if update lock was not there.
2
WITH NO UPDATE LOCKS
• If Update lock was not there then a transaction
would acquire a shared lock before updating a
resource.
• As shared locks are compatible, another concurrent
transaction would also place a shared lock on the
same resource.
• Now to update the resource, first transaction will try
to convert the shared lock to an exclusive lock.
3
WITH NO UPDATE LOCKS
CONTINUED……
• But the first transaction will fail to acquire an exclusive
lock because of shared lock placed by second
transaction.
• Similarly if the second transaction tries to acquire an
exclusive lock on the same row , it will also fail because
of shared lock placed by the first transaction resulting in
deadlock.
• This scenario is possible in Repeatable Read and
Serialization Isolation.
4
WITH UPDATE LOCKS
• To overcome this kind of deadlock, SQL Server
introduced update lock which is not compatible with
other locks.
• Only one transaction can acquire an update lock at a time
on a resource.
• Now just before updating the resource , the update lock
is converted to an exclusive lock.
5
6

More Related Content

What's hot

Introduce warden
Introduce wardenIntroduce warden
Introduce warden
Hieu Nguyen Trung
 
Training Slides: 103 - Basics - Simple Tungsten Clustering Installation
Training Slides: 103 - Basics - Simple Tungsten Clustering InstallationTraining Slides: 103 - Basics - Simple Tungsten Clustering Installation
Training Slides: 103 - Basics - Simple Tungsten Clustering Installation
Continuent
 
Blockchain sidechain brief
Blockchain sidechain briefBlockchain sidechain brief
Blockchain sidechain brief
manmohanpanda
 
Reactive Architecture
Reactive ArchitectureReactive Architecture
Reactive Architecture
Alexander Orlov
 
Vital Aspects of SSL Support in MySQL
Vital Aspects of SSL Support in MySQLVital Aspects of SSL Support in MySQL
Vital Aspects of SSL Support in MySQL
Lesa Cote
 
High performance java ee with j cache and cdi
High performance java ee with j cache and cdiHigh performance java ee with j cache and cdi
High performance java ee with j cache and cdi
Payara
 
Node js
Node jsNode js
The myth of unicorn
The myth of unicornThe myth of unicorn
The myth of unicorn
Isaiah Peng
 
Sqlviking
SqlvikingSqlviking
Sqlviking
Jonn Callahan
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
Betclic Everest Group Tech Team
 
Lightweight Orchestration with WSO2 ESB
Lightweight Orchestration with WSO2 ESBLightweight Orchestration with WSO2 ESB
Lightweight Orchestration with WSO2 ESB
WSO2
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happiness
Strannik_2013
 
Leveraging Mesos to manage container workloads at Samsung SAMI
Leveraging Mesos to manage container workloads at Samsung SAMI Leveraging Mesos to manage container workloads at Samsung SAMI
Leveraging Mesos to manage container workloads at Samsung SAMI
Niranjan Hanumegowda
 
JEE session 1
JEE session 1JEE session 1
JEE session 1
Smita B Kumar
 
OSDC 2011 | Marionette - System Control Utility by Cody Herriges
OSDC 2011 | Marionette - System Control Utility by Cody HerrigesOSDC 2011 | Marionette - System Control Utility by Cody Herriges
OSDC 2011 | Marionette - System Control Utility by Cody Herriges
NETWAYS
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
ArrrrCamp
 
Osdc - Meteor Intorduction
Osdc - Meteor IntorductionOsdc - Meteor Intorduction
Osdc - Meteor Intorduction
Ayush Narula
 
Smalltalk in the Cloud
Smalltalk in the CloudSmalltalk in the Cloud
Smalltalk in the Cloud
ESUG
 
UIT Presentation - Oct 17th, 2014
UIT Presentation - Oct 17th, 2014UIT Presentation - Oct 17th, 2014
UIT Presentation - Oct 17th, 2014
D. Darren MacDonald
 
MySQL At University Of Nottingham - 2018 MySQL Days
MySQL At University Of Nottingham - 2018 MySQL DaysMySQL At University Of Nottingham - 2018 MySQL Days
MySQL At University Of Nottingham - 2018 MySQL Days
Mark Swarbrick
 

What's hot (20)

Introduce warden
Introduce wardenIntroduce warden
Introduce warden
 
Training Slides: 103 - Basics - Simple Tungsten Clustering Installation
Training Slides: 103 - Basics - Simple Tungsten Clustering InstallationTraining Slides: 103 - Basics - Simple Tungsten Clustering Installation
Training Slides: 103 - Basics - Simple Tungsten Clustering Installation
 
Blockchain sidechain brief
Blockchain sidechain briefBlockchain sidechain brief
Blockchain sidechain brief
 
Reactive Architecture
Reactive ArchitectureReactive Architecture
Reactive Architecture
 
Vital Aspects of SSL Support in MySQL
Vital Aspects of SSL Support in MySQLVital Aspects of SSL Support in MySQL
Vital Aspects of SSL Support in MySQL
 
High performance java ee with j cache and cdi
High performance java ee with j cache and cdiHigh performance java ee with j cache and cdi
High performance java ee with j cache and cdi
 
Node js
Node jsNode js
Node js
 
The myth of unicorn
The myth of unicornThe myth of unicorn
The myth of unicorn
 
Sqlviking
SqlvikingSqlviking
Sqlviking
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
 
Lightweight Orchestration with WSO2 ESB
Lightweight Orchestration with WSO2 ESBLightweight Orchestration with WSO2 ESB
Lightweight Orchestration with WSO2 ESB
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happiness
 
Leveraging Mesos to manage container workloads at Samsung SAMI
Leveraging Mesos to manage container workloads at Samsung SAMI Leveraging Mesos to manage container workloads at Samsung SAMI
Leveraging Mesos to manage container workloads at Samsung SAMI
 
JEE session 1
JEE session 1JEE session 1
JEE session 1
 
OSDC 2011 | Marionette - System Control Utility by Cody Herriges
OSDC 2011 | Marionette - System Control Utility by Cody HerrigesOSDC 2011 | Marionette - System Control Utility by Cody Herriges
OSDC 2011 | Marionette - System Control Utility by Cody Herriges
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
 
Osdc - Meteor Intorduction
Osdc - Meteor IntorductionOsdc - Meteor Intorduction
Osdc - Meteor Intorduction
 
Smalltalk in the Cloud
Smalltalk in the CloudSmalltalk in the Cloud
Smalltalk in the Cloud
 
UIT Presentation - Oct 17th, 2014
UIT Presentation - Oct 17th, 2014UIT Presentation - Oct 17th, 2014
UIT Presentation - Oct 17th, 2014
 
MySQL At University Of Nottingham - 2018 MySQL Days
MySQL At University Of Nottingham - 2018 MySQL DaysMySQL At University Of Nottingham - 2018 MySQL Days
MySQL At University Of Nottingham - 2018 MySQL Days
 

Similar to Sql server update-lock

Concurrency in SQL Server (SQL Night #24)
Concurrency in SQL Server (SQL Night #24)Concurrency in SQL Server (SQL Night #24)
Concurrency in SQL Server (SQL Night #24)
Antonios Chatzipavlis
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...
Bob Pusateri
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...
Bob Pusateri
 
Pl sql-ch3
Pl sql-ch3Pl sql-ch3
Pl sql-ch3
Mukesh Tekwani
 
Understanding Locking Mechanisms in Database Systems
Understanding Locking Mechanisms in Database SystemsUnderstanding Locking Mechanisms in Database Systems
Understanding Locking Mechanisms in Database Systems
kiansahafi
 
Sql server concurrency
Sql server concurrencySql server concurrency
Sql server concurrency
Mahabubur Rahaman
 
Type LocK based in Concurrency Control.pptx
Type LocK based in Concurrency Control.pptxType LocK based in Concurrency Control.pptx
Type LocK based in Concurrency Control.pptx
emilinshyni2020
 
Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410
huangachou
 
Linux kernel development chapter 10
Linux kernel development chapter 10Linux kernel development chapter 10
Linux kernel development chapter 10
huangachou
 
Locking And Concurrency
Locking And ConcurrencyLocking And Concurrency
Locking And Concurrency
sqlserver.co.il
 
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
DAGEOP LTD
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
LLC NewLink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Sachintha Gunasena
 

Similar to Sql server update-lock (20)

Concurrency in SQL Server (SQL Night #24)
Concurrency in SQL Server (SQL Night #24)Concurrency in SQL Server (SQL Night #24)
Concurrency in SQL Server (SQL Night #24)
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (Chicago Suburb...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (SQL Saturday M...
 
Pl sql-ch3
Pl sql-ch3Pl sql-ch3
Pl sql-ch3
 
Understanding Locking Mechanisms in Database Systems
Understanding Locking Mechanisms in Database SystemsUnderstanding Locking Mechanisms in Database Systems
Understanding Locking Mechanisms in Database Systems
 
Sql server concurrency
Sql server concurrencySql server concurrency
Sql server concurrency
 
Type LocK based in Concurrency Control.pptx
Type LocK based in Concurrency Control.pptxType LocK based in Concurrency Control.pptx
Type LocK based in Concurrency Control.pptx
 
Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410
 
Linux kernel development chapter 10
Linux kernel development chapter 10Linux kernel development chapter 10
Linux kernel development chapter 10
 
Locking And Concurrency
Locking And ConcurrencyLocking And Concurrency
Locking And Concurrency
 
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
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
 

Recently uploaded

Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 

Recently uploaded (20)

Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 

Sql server update-lock

  • 2. BACKGROUND • Locks are used by SQL Server DB engine to protect a resource from modification by concurrent transactions simultaneously. • Among many locks used by SQL Server Update lock is one of the least understood locks. • This lock is used by SQL Server Database Engine to prevent a kind of deadlock which would have been possible if update lock was not there. 2
  • 3. WITH NO UPDATE LOCKS • If Update lock was not there then a transaction would acquire a shared lock before updating a resource. • As shared locks are compatible, another concurrent transaction would also place a shared lock on the same resource. • Now to update the resource, first transaction will try to convert the shared lock to an exclusive lock. 3
  • 4. WITH NO UPDATE LOCKS CONTINUED…… • But the first transaction will fail to acquire an exclusive lock because of shared lock placed by second transaction. • Similarly if the second transaction tries to acquire an exclusive lock on the same row , it will also fail because of shared lock placed by the first transaction resulting in deadlock. • This scenario is possible in Repeatable Read and Serialization Isolation. 4
  • 5. WITH UPDATE LOCKS • To overcome this kind of deadlock, SQL Server introduced update lock which is not compatible with other locks. • Only one transaction can acquire an update lock at a time on a resource. • Now just before updating the resource , the update lock is converted to an exclusive lock. 5
  • 6. 6