SlideShare a Scribd company logo
1 of 55
Download to read offline
Unit – 9
Distributed Deadlock
&
Recovery
Outlines..
• Deadlock in Distributed Systems
• Recovery in DBMS
• Advanced recovery techniques
– Shadow Paging
– Fuzzy checkpoint
– ARIES
– RAID levels
• Two Phase and Three Phase commit protocols
1/11/2017 2Prof. Dhaval R. Chandarana
Deadlock
• A deadlock can occur because transactions wait for
one another. Informally, a deadlock situation is a set
of requests that can never be granted by the
concurrency control mechanism.
• A deadlock can be indicated by a cycle in the wait-
for-graph (WFG).
• In computer science, deadlock refers to a specific
condition when two or more processes are each
waiting for another to release a resource, or more
than two processes are waiting for resources in a
circular chain.
1/11/2017 3Prof. Dhaval R. Chandarana
Deadlock
1/11/2017 4Prof. Dhaval R. Chandarana
Necessary Condition for Deadlock
• Mutual exclusion: A resource may be acquired
exclusively by only one process at a time.
1/11/2017 5Prof. Dhaval R. Chandarana
Necessary Condition for Deadlock
• Hold and wait: Processes currently holding resources
that were granted earlier can request new resources.
1/11/2017 6Prof. Dhaval R. Chandarana
Necessary Condition for Deadlock
• No preemption: Once a process has obtained a
resources, the system cannot remove it from the
process control until the process has finished using
the resource.
1/11/2017 7Prof. Dhaval R. Chandarana
Necessary Condition for Deadlock
• Circular wait: A circular chain of hold and wait
condition exists in the system.
1/11/2017 8Prof. Dhaval R. Chandarana
Deadlock Detection
• Deadlock detection is the process of actually
determining that a deadlock exists and identifying
the processes and resources involved in the
deadlock.
• Detection of a cycle in WFG proceeds concurrently
with normal operation in main of deadlock
detection.
1/11/2017 9Prof. Dhaval R. Chandarana
Deadlock Prevention
• The deadlock prevention approach does not
allow any transaction to acquire locks that will
lead to deadlocks. The convention is that
when more than one transactions request for
locking the same data item, only one of them
is granted the lock.
• One of the most popular deadlock prevention
methods is pre-acquisition of all the locks.
1/11/2017 10Prof. Dhaval R. Chandarana
Deadlock Avoidance
• The deadlock avoidance approach handles deadlocks before they
occur. It analyzes the transactions and the locks to determine
whether or not waiting leads to a deadlock.
• There are two algorithms for this purpose, namely wait-die and
wound-wait.
• Let us assume that there are two transactions, T1 and T2, where T1
tries to lock a data item which is already locked by T2. The
algorithms are as follows −
• Wait-Die − If T1 is older than T2, T1 is allowed to wait. Otherwise, if
T1 is younger than T2, T1 is aborted and later restarted.
• Wound-Wait − If T1 is older than T2, T2 is aborted and later
restarted. Otherwise, if T1 is younger than T2, T1 is allowed to wait.
1/11/2017 11Prof. Dhaval R. Chandarana
Recovery in DBMS
• Recovery refers to restoring a system to its normal operation
state.
• Once a failure has occurred, it is essential that the process
where the failure happened can recover to correct state.
• Following are some solution on process recovery:
1. Reclaim resources allocated to process.
2. Undo modification made to database.
3. Restart the process.
4. Or Restart the process from point of failure and resume
execution.
1/11/2017 12Prof. Dhaval R. Chandarana
Concept of Recovery
Fault
Fault
Error
Valid
state
Erroneous state
1/11/2017 13Prof. Dhaval R. Chandarana
Concept of Recovery
• System failure: System does not meet requirements
• Erroneous system state: State which could lead to a system
failure by a sequence of valid state transitions.
• Error: the part of the system state which different from its
intended value.
• Fault: Abnormal physical condition. Eg, design errors,
manufacturing problems, damage, external disturbances.
1/11/2017 14Prof. Dhaval R. Chandarana
Classification of Failure
• In a distributed database system, we need to deal with four
types of failures: transaction failures (aborts), site (system)
failures, media (disk) failures, and communication line
failures.
• Some of these are due to hardware and others are due to
software.
• Software failures are typically caused by “bugs” in the code.
As stated before, most of the software failures are soft
failures.
1/11/2017 15Prof. Dhaval R. Chandarana
1 Transaction Failures
• Transactions can fail for a number of reasons. Failure can be
due to an error in the transaction caused by incorrect input
data as well as the detection of a present or potential
deadlock.
• some concurrency control algorithms do not permit a
transaction to proceed or even to wait if the data that they
attempt to access are currently being accessed by another
transaction. This might also be considered a failure.
1/11/2017 16Prof. Dhaval R. Chandarana
2 Site (System) Failures
• A system failure is always assumed to result in the loss of
main memory contents. Therefore, any part of the database
that was in main memory buffers is lost as a result of a system
failure.
• In distributed database terminology, system failures are
typically referred to as site failures, since they result in the
failed site being unreachable from other sites in the
distributed system.
• Total failure refers to the simultaneous failure of all sites in
the distributed system
• Partial failure indicates the failure of only some sites while
the others remain operational.
1/11/2017 17Prof. Dhaval R. Chandarana
3 Media Failures
• Media failure refers to the failures of the secondary storage
devices that store the database.
• Such failures may be due to operating system errors, as well
as to hardware faults such as head crashes or controller
failures.
• The important point from the perspective of DBMS reliability
is that all or part of the database that is on the secondary
storage is considered to be destroyed and inaccessible.
1/11/2017 18Prof. Dhaval R. Chandarana
4 Communication Failures
• Communication failures, however, are unique to the
distributed case.
• There are a number of types of communication failures. The
most common ones are the errors in the messages,
improperly ordered messages, lost (or undeliverable)
messages, and communication line failures.
• Lost or undeliverable messages are typically the consequence
of communication line failures or (destination) site failures.
• The detection will be facilitated by the use of timers and a
timeout mechanism that keeps track of how long it has been
since the sender site has not received a confirmation from the
destination site about the receipt of a message.
1/11/2017 19Prof. Dhaval R. Chandarana
Methods to control failure
• Failure affected transactions must be aborted.
• Site failure message is broadcasted to all sites.
• Checking must be done periodically to see whether the failed
site has recovered or not.
• After restarting the failure site, site must initiate a recovery
procedure to abort all partial transaction that were active at
the time of failure.
1/11/2017 20Prof. Dhaval R. Chandarana
Different techniques of recoverability
• The additional components and abnormal algorithm can be
added to a system these components and algorithms attempt
to ensure that occurrences of erroneous states do not result
in later system failure ideally, they removes these errors and
restore them to “correct” states from which normal
processing can continue. These additional component and
abnormal algorithm, called recovery technique.
 Backward and Forward Error Recovery
 Log Based Recovery
 Write-Ahead Logging Protocol
1/11/2017 21Prof. Dhaval R. Chandarana
Backward and Forward Error Recovery
Recovery
Forward-error Backward-error
Operational-base State-based
1/11/2017 22Prof. Dhaval R. Chandarana
Prof. Dhaval R. Chandarana 23
•Failure recovery: restore an erroneous state to an error-free state
•Approaches to failure recovery:
– Forward-error recovery:
• Remove errors in process/system state (if errors can be completely assessed)
• Continue process/system forward execution
– Backward-error recovery:
• Restore process/system to previous error-free state and restart from there
•Comparison: Forward vs. Backward error recovery
– Backward-error recovery
(+)Simple to implement
(+)Can be used as general recovery mechanism
(-) Performance penalty
(-) No guarantee that fault does not occur again
(-) Some components cannot be recovered
– Forward-error Recovery
(+)Less overhead
(-) Limited use, i.e. only when impact of faults understood
(-) Cannot be used as general mechanism for error recovery
Backward and Forward Error Recovery
1/11/2017
Prof. Dhaval R. Chandarana 24
•Principle: restore process/system to a known, error-free “recovery point”/ “checkpoint”.
•System model:
•Approaches:
(1) Operation-based approach
(2) State-based approach
Backward-Error Recovery: Basic approach
CPU
Main memory
secondary
storage
stable
storage
Storage that
maintains
information in
the event of
system failure
Bring object to MM
to be accessed
Store logs and
recovery points
Write object back
if modified
1/11/2017
Prof. Dhaval R. Chandarana 25
•Principle:
– Record all changes made to state of process (‘audit trail’ or ‘log’) such that process
can be returned to a previous state
– Example: A transaction based environment where transactions update a database
• It is possible to commit or undo updates on a per-transaction basis
• A commit indicates that the transaction on the object was successful and changes are
permanent
(1.a) Updating-in-place
• Principle: every update (write) operation to an object creates a log in stable storage
that can be used to ‘undo’ and ‘redo’ the operation
• Log content: object name, old object state, new object state
• Implementation of a recoverable update operation:
– Do operation: update object and write log record
– Undo operation: log(old) -> object (undoes the action performed by a do)
– Redo operation: log(new) -> object (redoes the action performed by a do)
– Display operation: display log record (optional)
• Problem: a ‘do’ cannot be recovered if system crashes after write object but before
log record write
(1.b) The write-ahead log protocol
• Principle: write log record before updating object
(1) The Operation-based Approach
1/11/2017
Prof. Dhaval R. Chandarana 26
•Principle: establish frequent ‘recovery points’ or ‘checkpoints’ saving the entire
state of process
•Actions:
– ‘Checkpointing’ or ‘taking a checkpoint’: saving process state
– ‘Rolling back’ a process: restoring a process to a prior state
Note: A process should be rolled back to the most recent ‘recovery point’ to
minimize the overhead and delays in the completion of the process
•Shadow Pages: Special case of state-based approach
– Only a part of the system state is saved to minimize recovery
– When an object is modified, page containing object is first copied on stable
storage (shadow page)
– If process successfully commits: shadow page discarded and modified page is
made part of the database
– If process fails: shadow page used and the modified page discarded
(2) State-based Approach
1/11/2017
Recovery in concurrent systems
• Issue: if one of a set of cooperating processes fails and has to be rolled back to a
recovery point, all processes it communicated with since the recovery point have to be
rolled back.
• Conclusion: In concurrent and/or distributed systems all cooperating processes have to
establish recovery points
• Orphan messages and the domino effect
– Case 1: failure of X after x3 : no impact on Y or Z
– Case 2: failure of Y after sending msg. ‘m’
• Y rolled back to y2
• ‘m’ ≡ orphan massage
• X rolled back to x2
– Case 3: failure of Z after z2
• Y has to roll back to y1
• X has to roll back to x1 Domino Effect
• Z has to roll back to z1
X
Y
Z
y1
x1
z1 z2
x2
y2
x3
m
Time
1/11/2017 27Prof. Dhaval R. Chandarana
Lost messages
• Assume that x1 and y1 are the only recovery points for processes X and Y, respectively
• Assume Y fails after receiving message ‘m’
• Y rolled back to y1,X rolled back to x1
• Message ‘m’ is lost
Note: there is no distinction between this case and the case where message ‘m’ is lost in
communication channel and processes X and Y are in states x1 and y1, respectively
X
Y y1
x1
m
Time
Failure
1/11/2017 28Prof. Dhaval R. Chandarana
Log Based Recovery
• When failures occur the following operation
that use the log are executed.
• UNDO: restore database to state prior to
execution.
• REDO: perform the changes to the database
over again.
1/11/2017 29Prof. Dhaval R. Chandarana
UNDO
1/11/2017 30Prof. Dhaval R. Chandarana
REDO
1/11/2017 31Prof. Dhaval R. Chandarana
Write-Ahead Logging Protocol
• write-ahead logging (WAL) is a family of techniques for
providing atomicity and durability in database systems.
• In a system using WAL, all modifications are written to a log
before they are applied. Usually both redo and undo information
is stored in the log.
• The purpose of this can be illustrated by an example. Imagine a
program that is in the middle of performing some operation
when the machine it is running on loses power. Upon restart,
that program might well need to know whether the operation it
was performing succeeded, half-succeeded, or failed. If a write-
ahead log is used, the program can check this log and compare
what it was supposed to be doing when it unexpectedly lost
power to what was actually done. On the basis of this
comparison, the program could decide to undo what it had
started, complete what it had started, or keep things as they are.1/11/2017 32Prof. Dhaval R. Chandarana
Write-Ahead Logging Protocol
1/11/2017 33Prof. Dhaval R. Chandarana
Advanced recovery techniques
• Shadow Paging
• Fuzzy checkpoint
• ARIES
• RAID levels
1/11/2017 34Prof. Dhaval R. Chandarana
Shadow Paging
• It is inconvenient to maintain logs of all
transactions for the purposes of recovery. An
alternative is to use a system of shadow
paging.
• This is where the database is divided into
pages that may be stored in any order on the
disk.
• In order to identify the location of any given
page, we use something called a page table.
1/11/2017 35Prof. Dhaval R. Chandarana
Shadow Paging
• During the life of a transaction two page tables
are maintained, one called a shadow page table
and current page table.
• When a transaction begins both of these page
tables point to the same locations (are identical).
• However during the lifetime of a transaction
changes may be made update values etc. So
whenever we update a page in the database we
always write the updated page to a new location.
• This means that when we then update our
current page table to reflect the changes that
have been made.
1/11/2017 36Prof. Dhaval R. Chandarana
Shadow Paging
1/11/2017 37Prof. Dhaval R. Chandarana
Fuzzy checkpoint
• In a fuzzy checkpoint, the database server does not flush
the modified pages in the shared-memory buffer pool to
disk for certain types of operations, called fuzzy
operations.
• When a fuzzy checkpoint completes, the pages might not
be consistent with each other, because the database
server does not flush all data pages to disk.
• A fuzzy checkpoint completes much more quickly than a
full checkpoint and reduces the amount of physical
logging during heavy update activity. When necessary,
the database server performs a full checkpoint to ensure
the physical consistency of all data on disk.
1/11/2017 38Prof. Dhaval R. Chandarana
Fuzzy checkpoint
• Fuzzy Operations
– Inserts
– Updates
– Deletes
• Important:
– Fuzzy checkpoints are disabled for the primary
and secondary servers in a High-Availability Data
Replication pair.
1/11/2017 39Prof. Dhaval R. Chandarana
ARIES
• In computer science, Algorithms for Recovery
and Isolation Exploiting Semantics, or ARIES
is a recovery algorithm designed to work with
a no-force, steal database approach; it is used
by IBM DB2, Microsoft SQL Server and many
other database systems.
1/11/2017 40Prof. Dhaval R. Chandarana
Principles lie behind ARIES
• Three main principles lie behind ARIES
• Write-ahead logging: Any change to an object is first
recorded in the log, and the log must be written to
stable storage before changes to the object are written
to disk.
• Repeating history during Redo: On restart after a
crash, ARIES retraces the actions of a database before
the crash and brings the system back to the exact state
that it was in before the crash. Then it undoes the
transactions still active at crash time.
• Logging changes during Undo: Changes made to the
database while undoing transactions are logged to
ensure such an action isn't repeated in the event of
repeated restarts.
1/11/2017 41Prof. Dhaval R. Chandarana
ARIES LSN
1/11/2017 42Prof. Dhaval R. Chandarana
RAID Level
Redundant Array of Inexpensive Disks
RAID Level 0 Striping
RAID Level 1
Mirroring and performance
improvements
RAID Level 2 Byte-level parity
RAID Level 3 Block-level parity
RAID Level 4 Rotating parity
RAID Level 5 Tolerates failure of two disk drives
1/11/2017 43Prof. Dhaval R. Chandarana
RAID Level-0
file data block 1block 0 block 2 block 3 block 4
Disk 0 Disk 1
0 block 0
1 block 2
2 block 4
3
4
5
sectors
0 block 1
1 block 3
2
3
4
5
sectors
1/11/2017 44Prof. Dhaval R. Chandarana
RAID Level-1
file data block 1block 0 block 2 block 3 block 4
Disk 0 Disk 1
0 block 0
1 block 1
2 block 2
3 block 3
4 block 4
5
sectors
0 block 0
1 block 1
2 block 2
3 block 3
4 block 4
5
sectors
1/11/2017 45Prof. Dhaval R. Chandarana
RAID Level - 2
• RAID Level 2 uses concept of parallel access
technique. It works on the word(byte) level. So
each strip stores one bit. It takes data striping to
the extreme, writing only 1 bit per strip, instead
of in arbitrary size block. For this reason, it
require a minimum, of 8 surface to write data to
the hard disk.
• In RAID level 2, strip are very small, so when a
block is read, all disks are accessed in parallel.
• Hamming code generation is time consuming,
therefore RAID level 2 is too slow for most
commercial application.
1/11/2017 46Prof. Dhaval R. Chandarana
RAID Level - 2
Error Correction Code (ECC)
1/11/2017 47Prof. Dhaval R. Chandarana
RAID Level - 3
1/11/2017 48Prof. Dhaval R. Chandarana
RAID Level - 4
1/11/2017 49Prof. Dhaval R. Chandarana
RAID Level - 5
1/11/2017 50Prof. Dhaval R. Chandarana
RAID Level - 6
1/11/2017 51Prof. Dhaval R. Chandarana
TwoPhaseCommitProtocols
1/11/2017 52Prof. Dhaval R. Chandarana
State Transitions in 2PC Protocol
1/11/2017 53Prof. Dhaval R. Chandarana
Three Phase Commit Protocols
1/11/2017 54Prof. Dhaval R. Chandarana
State Transitions in 3PC Protocol
1/11/2017 55Prof. Dhaval R. Chandarana

More Related Content

What's hot

Deadlock management
Deadlock managementDeadlock management
Deadlock managementAhmed kasim
 
Join ordering in fragment queries
Join ordering in fragment queriesJoin ordering in fragment queries
Join ordering in fragment queriesIfzalhussainkhan
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Gyanmanjari Institute Of Technology
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database SystemMeghaj Mallick
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating SystemsDr Sandeep Kumar Poonia
 
Distributed transaction
Distributed transactionDistributed transaction
Distributed transactionMohitKothari26
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemMidhun Sankar
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Meghaj Mallick
 
2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOL2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOLKABILESH RAMAR
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 
Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!Ashish K
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency ControlDilum Bandara
 

What's hot (20)

Deadlock management
Deadlock managementDeadlock management
Deadlock management
 
Join ordering in fragment queries
Join ordering in fragment queriesJoin ordering in fragment queries
Join ordering in fragment queries
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database System
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems
 
Distributed transaction
Distributed transactionDistributed transaction
Distributed transaction
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Distributed DBMS - Unit 5 - Semantic Data Control
Distributed DBMS - Unit 5 - Semantic Data ControlDistributed DBMS - Unit 5 - Semantic Data Control
Distributed DBMS - Unit 5 - Semantic Data Control
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
Distributed DBMS - Unit 1 - Introduction
Distributed DBMS - Unit 1 - IntroductionDistributed DBMS - Unit 1 - Introduction
Distributed DBMS - Unit 1 - Introduction
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
 
2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOL2 PHASE COMMIT PROTOCOL
2 PHASE COMMIT PROTOCOL
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency control
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
 

Similar to Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery

Fazal rafi.. database concurancy control and recovery
Fazal rafi.. database concurancy control and recoveryFazal rafi.. database concurancy control and recovery
Fazal rafi.. database concurancy control and recoverySofthat IT Solutions
 
Oracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsOracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsVigilant Technologies
 
recovery management with concurrent controls
recovery management with concurrent controlsrecovery management with concurrent controls
recovery management with concurrent controlsSiva Priya
 
The Database Environment Chapter 12
The Database Environment Chapter 12The Database Environment Chapter 12
The Database Environment Chapter 12Jeanie Arnoco
 
Performance Tuning
Performance TuningPerformance Tuning
Performance TuningJannet Peetz
 
Fault tolerance in distributed systems
Fault tolerance in distributed systemsFault tolerance in distributed systems
Fault tolerance in distributed systemssumitjain2013
 
Operating system Interview Questions
Operating system Interview QuestionsOperating system Interview Questions
Operating system Interview QuestionsKuntal Bhowmick
 
What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...Raj vardhan
 
Fault tolerant presentation
Fault tolerant presentationFault tolerant presentation
Fault tolerant presentationskadyan1
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 
What is Database Management System
What is Database Management SystemWhat is Database Management System
What is Database Management SystemAbhiPatel171
 

Similar to Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery (20)

Guide on Raid Data Recovery
Guide on Raid Data RecoveryGuide on Raid Data Recovery
Guide on Raid Data Recovery
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
 
Fazal rafi.. database concurancy control and recovery
Fazal rafi.. database concurancy control and recoveryFazal rafi.. database concurancy control and recovery
Fazal rafi.. database concurancy control and recovery
 
Oracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsOracle EBS Production Support - Recommendations
Oracle EBS Production Support - Recommendations
 
recovery management
recovery managementrecovery management
recovery management
 
recovery management with concurrent controls
recovery management with concurrent controlsrecovery management with concurrent controls
recovery management with concurrent controls
 
The Database Environment Chapter 12
The Database Environment Chapter 12The Database Environment Chapter 12
The Database Environment Chapter 12
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
Fault tolerance in distributed systems
Fault tolerance in distributed systemsFault tolerance in distributed systems
Fault tolerance in distributed systems
 
Operating system Interview Questions
Operating system Interview QuestionsOperating system Interview Questions
Operating system Interview Questions
 
What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...
 
Fault tolerant presentation
Fault tolerant presentationFault tolerant presentation
Fault tolerant presentation
 
UNIT I-Processes.pptx
UNIT I-Processes.pptxUNIT I-Processes.pptx
UNIT I-Processes.pptx
 
SVCC-2014
SVCC-2014SVCC-2014
SVCC-2014
 
Crash recovery in database
Crash recovery in databaseCrash recovery in database
Crash recovery in database
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
 
What is Database Management System
What is Database Management SystemWhat is Database Management System
What is Database Management System
 

More from Gyanmanjari Institute Of Technology

More from Gyanmanjari Institute Of Technology (20)

WD - Unit - 7 - Advanced Concepts
WD - Unit - 7 - Advanced ConceptsWD - Unit - 7 - Advanced Concepts
WD - Unit - 7 - Advanced Concepts
 
WD - Unit - 4 - PHP Basics
WD - Unit - 4 - PHP BasicsWD - Unit - 4 - PHP Basics
WD - Unit - 4 - PHP Basics
 
WD - Unit - 3 - Java Script
WD - Unit - 3 - Java ScriptWD - Unit - 3 - Java Script
WD - Unit - 3 - Java Script
 
WD - Unit - 6 - Database Connectivity using PHP
WD - Unit - 6 - Database Connectivity using PHPWD - Unit - 6 - Database Connectivity using PHP
WD - Unit - 6 - Database Connectivity using PHP
 
WD - Unit - 5 - Session and State Management using PHP
WD - Unit - 5 - Session and State Management using PHPWD - Unit - 5 - Session and State Management using PHP
WD - Unit - 5 - Session and State Management using PHP
 
WD - Unit - 2 - HTML & CSS
WD - Unit - 2 - HTML & CSSWD - Unit - 2 - HTML & CSS
WD - Unit - 2 - HTML & CSS
 
WD - Unit - 1 - Introduction
WD - Unit - 1 - IntroductionWD - Unit - 1 - Introduction
WD - Unit - 1 - Introduction
 
OSV - Unit - 8 - Unix/Linux Operating System
OSV - Unit - 8 - Unix/Linux Operating SystemOSV - Unit - 8 - Unix/Linux Operating System
OSV - Unit - 8 - Unix/Linux Operating System
 
OSV - Unit - 10 - Approaches to Virtualization
OSV - Unit - 10 - Approaches to VirtualizationOSV - Unit - 10 - Approaches to Virtualization
OSV - Unit - 10 - Approaches to Virtualization
 
OSV - Unit - 9 - Virtualization Concepts
OSV - Unit - 9 - Virtualization ConceptsOSV - Unit - 9 - Virtualization Concepts
OSV - Unit - 9 - Virtualization Concepts
 
OSV - Unit - 7 - I/O Management & Disk scheduling
OSV - Unit - 7 - I/O Management & Disk schedulingOSV - Unit - 7 - I/O Management & Disk scheduling
OSV - Unit - 7 - I/O Management & Disk scheduling
 
OSV - Unit - 6 - Memory Management
OSV - Unit - 6 - Memory ManagementOSV - Unit - 6 - Memory Management
OSV - Unit - 6 - Memory Management
 
CNS - Unit - 10 - Web Security Threats and Approaches
CNS - Unit - 10 - Web Security Threats and ApproachesCNS - Unit - 10 - Web Security Threats and Approaches
CNS - Unit - 10 - Web Security Threats and Approaches
 
OSV - Unit - 5 - Deadlock
OSV - Unit - 5 - DeadlockOSV - Unit - 5 - Deadlock
OSV - Unit - 5 - Deadlock
 
OSV - Unit - 4 - Inter Process Communication
OSV - Unit - 4 - Inter Process CommunicationOSV - Unit - 4 - Inter Process Communication
OSV - Unit - 4 - Inter Process Communication
 
OSV - Unit - 3 - Concurrency
OSV - Unit - 3 - ConcurrencyOSV - Unit - 3 - Concurrency
OSV - Unit - 3 - Concurrency
 
OSV - Unit - 2 - Process and Threads Management
OSV - Unit - 2 - Process and Threads ManagementOSV - Unit - 2 - Process and Threads Management
OSV - Unit - 2 - Process and Threads Management
 
CNS - Unit - 8 - Key Management and Distribution
CNS - Unit - 8 - Key Management and DistributionCNS - Unit - 8 - Key Management and Distribution
CNS - Unit - 8 - Key Management and Distribution
 
CNS - Unit - 7 - Digital Signature
CNS - Unit - 7 - Digital SignatureCNS - Unit - 7 - Digital Signature
CNS - Unit - 7 - Digital Signature
 
CNS - Unit - 6 - Message Authentication Code
CNS - Unit - 6 - Message Authentication CodeCNS - Unit - 6 - Message Authentication Code
CNS - Unit - 6 - Message Authentication Code
 

Recently uploaded

SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....santhyamuthu1
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesDIPIKA83
 
Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...sahb78428
 
nvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxnvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxjasonsedano2
 
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecGuardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecTrupti Shiralkar, CISSP
 
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdfsdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdfJulia Kaye
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxJoseeMusabyimana
 
ChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai searchChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai searchrohitcse52
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfRedhwan Qasem Shaddad
 
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxSUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxNaveenVerma126
 
Gender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 ProjectGender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 Projectreemakb03
 
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratoryدليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide LaboratoryBahzad5
 
Summer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdf
Summer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdfSummer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdf
Summer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdfNaveenVerma126
 
Multicomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfMulticomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfGiovanaGhasary1
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptxSaiGouthamSunkara
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Sean Meyn
 
Landsman converter for power factor improvement
Landsman converter for power factor improvementLandsman converter for power factor improvement
Landsman converter for power factor improvementVijayMuni2
 

Recently uploaded (20)

SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display Devices
 
Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...
 
nvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxnvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptx
 
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecGuardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
 
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdfsdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
 
Lecture 4 .pdf
Lecture 4                              .pdfLecture 4                              .pdf
Lecture 4 .pdf
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptx
 
ChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai searchChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai search
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdf
 
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxSUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
 
Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptx
 
Lecture 2 .pdf
Lecture 2                           .pdfLecture 2                           .pdf
Lecture 2 .pdf
 
Gender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 ProjectGender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 Project
 
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratoryدليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
 
Summer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdf
Summer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdfSummer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdf
Summer training report on BUILDING CONSTRUCTION for DIPLOMA Students.pdf
 
Multicomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfMulticomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdf
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptx
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
 
Landsman converter for power factor improvement
Landsman converter for power factor improvementLandsman converter for power factor improvement
Landsman converter for power factor improvement
 

Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery

  • 1. Unit – 9 Distributed Deadlock & Recovery
  • 2. Outlines.. • Deadlock in Distributed Systems • Recovery in DBMS • Advanced recovery techniques – Shadow Paging – Fuzzy checkpoint – ARIES – RAID levels • Two Phase and Three Phase commit protocols 1/11/2017 2Prof. Dhaval R. Chandarana
  • 3. Deadlock • A deadlock can occur because transactions wait for one another. Informally, a deadlock situation is a set of requests that can never be granted by the concurrency control mechanism. • A deadlock can be indicated by a cycle in the wait- for-graph (WFG). • In computer science, deadlock refers to a specific condition when two or more processes are each waiting for another to release a resource, or more than two processes are waiting for resources in a circular chain. 1/11/2017 3Prof. Dhaval R. Chandarana
  • 5. Necessary Condition for Deadlock • Mutual exclusion: A resource may be acquired exclusively by only one process at a time. 1/11/2017 5Prof. Dhaval R. Chandarana
  • 6. Necessary Condition for Deadlock • Hold and wait: Processes currently holding resources that were granted earlier can request new resources. 1/11/2017 6Prof. Dhaval R. Chandarana
  • 7. Necessary Condition for Deadlock • No preemption: Once a process has obtained a resources, the system cannot remove it from the process control until the process has finished using the resource. 1/11/2017 7Prof. Dhaval R. Chandarana
  • 8. Necessary Condition for Deadlock • Circular wait: A circular chain of hold and wait condition exists in the system. 1/11/2017 8Prof. Dhaval R. Chandarana
  • 9. Deadlock Detection • Deadlock detection is the process of actually determining that a deadlock exists and identifying the processes and resources involved in the deadlock. • Detection of a cycle in WFG proceeds concurrently with normal operation in main of deadlock detection. 1/11/2017 9Prof. Dhaval R. Chandarana
  • 10. Deadlock Prevention • The deadlock prevention approach does not allow any transaction to acquire locks that will lead to deadlocks. The convention is that when more than one transactions request for locking the same data item, only one of them is granted the lock. • One of the most popular deadlock prevention methods is pre-acquisition of all the locks. 1/11/2017 10Prof. Dhaval R. Chandarana
  • 11. Deadlock Avoidance • The deadlock avoidance approach handles deadlocks before they occur. It analyzes the transactions and the locks to determine whether or not waiting leads to a deadlock. • There are two algorithms for this purpose, namely wait-die and wound-wait. • Let us assume that there are two transactions, T1 and T2, where T1 tries to lock a data item which is already locked by T2. The algorithms are as follows − • Wait-Die − If T1 is older than T2, T1 is allowed to wait. Otherwise, if T1 is younger than T2, T1 is aborted and later restarted. • Wound-Wait − If T1 is older than T2, T2 is aborted and later restarted. Otherwise, if T1 is younger than T2, T1 is allowed to wait. 1/11/2017 11Prof. Dhaval R. Chandarana
  • 12. Recovery in DBMS • Recovery refers to restoring a system to its normal operation state. • Once a failure has occurred, it is essential that the process where the failure happened can recover to correct state. • Following are some solution on process recovery: 1. Reclaim resources allocated to process. 2. Undo modification made to database. 3. Restart the process. 4. Or Restart the process from point of failure and resume execution. 1/11/2017 12Prof. Dhaval R. Chandarana
  • 13. Concept of Recovery Fault Fault Error Valid state Erroneous state 1/11/2017 13Prof. Dhaval R. Chandarana
  • 14. Concept of Recovery • System failure: System does not meet requirements • Erroneous system state: State which could lead to a system failure by a sequence of valid state transitions. • Error: the part of the system state which different from its intended value. • Fault: Abnormal physical condition. Eg, design errors, manufacturing problems, damage, external disturbances. 1/11/2017 14Prof. Dhaval R. Chandarana
  • 15. Classification of Failure • In a distributed database system, we need to deal with four types of failures: transaction failures (aborts), site (system) failures, media (disk) failures, and communication line failures. • Some of these are due to hardware and others are due to software. • Software failures are typically caused by “bugs” in the code. As stated before, most of the software failures are soft failures. 1/11/2017 15Prof. Dhaval R. Chandarana
  • 16. 1 Transaction Failures • Transactions can fail for a number of reasons. Failure can be due to an error in the transaction caused by incorrect input data as well as the detection of a present or potential deadlock. • some concurrency control algorithms do not permit a transaction to proceed or even to wait if the data that they attempt to access are currently being accessed by another transaction. This might also be considered a failure. 1/11/2017 16Prof. Dhaval R. Chandarana
  • 17. 2 Site (System) Failures • A system failure is always assumed to result in the loss of main memory contents. Therefore, any part of the database that was in main memory buffers is lost as a result of a system failure. • In distributed database terminology, system failures are typically referred to as site failures, since they result in the failed site being unreachable from other sites in the distributed system. • Total failure refers to the simultaneous failure of all sites in the distributed system • Partial failure indicates the failure of only some sites while the others remain operational. 1/11/2017 17Prof. Dhaval R. Chandarana
  • 18. 3 Media Failures • Media failure refers to the failures of the secondary storage devices that store the database. • Such failures may be due to operating system errors, as well as to hardware faults such as head crashes or controller failures. • The important point from the perspective of DBMS reliability is that all or part of the database that is on the secondary storage is considered to be destroyed and inaccessible. 1/11/2017 18Prof. Dhaval R. Chandarana
  • 19. 4 Communication Failures • Communication failures, however, are unique to the distributed case. • There are a number of types of communication failures. The most common ones are the errors in the messages, improperly ordered messages, lost (or undeliverable) messages, and communication line failures. • Lost or undeliverable messages are typically the consequence of communication line failures or (destination) site failures. • The detection will be facilitated by the use of timers and a timeout mechanism that keeps track of how long it has been since the sender site has not received a confirmation from the destination site about the receipt of a message. 1/11/2017 19Prof. Dhaval R. Chandarana
  • 20. Methods to control failure • Failure affected transactions must be aborted. • Site failure message is broadcasted to all sites. • Checking must be done periodically to see whether the failed site has recovered or not. • After restarting the failure site, site must initiate a recovery procedure to abort all partial transaction that were active at the time of failure. 1/11/2017 20Prof. Dhaval R. Chandarana
  • 21. Different techniques of recoverability • The additional components and abnormal algorithm can be added to a system these components and algorithms attempt to ensure that occurrences of erroneous states do not result in later system failure ideally, they removes these errors and restore them to “correct” states from which normal processing can continue. These additional component and abnormal algorithm, called recovery technique.  Backward and Forward Error Recovery  Log Based Recovery  Write-Ahead Logging Protocol 1/11/2017 21Prof. Dhaval R. Chandarana
  • 22. Backward and Forward Error Recovery Recovery Forward-error Backward-error Operational-base State-based 1/11/2017 22Prof. Dhaval R. Chandarana
  • 23. Prof. Dhaval R. Chandarana 23 •Failure recovery: restore an erroneous state to an error-free state •Approaches to failure recovery: – Forward-error recovery: • Remove errors in process/system state (if errors can be completely assessed) • Continue process/system forward execution – Backward-error recovery: • Restore process/system to previous error-free state and restart from there •Comparison: Forward vs. Backward error recovery – Backward-error recovery (+)Simple to implement (+)Can be used as general recovery mechanism (-) Performance penalty (-) No guarantee that fault does not occur again (-) Some components cannot be recovered – Forward-error Recovery (+)Less overhead (-) Limited use, i.e. only when impact of faults understood (-) Cannot be used as general mechanism for error recovery Backward and Forward Error Recovery 1/11/2017
  • 24. Prof. Dhaval R. Chandarana 24 •Principle: restore process/system to a known, error-free “recovery point”/ “checkpoint”. •System model: •Approaches: (1) Operation-based approach (2) State-based approach Backward-Error Recovery: Basic approach CPU Main memory secondary storage stable storage Storage that maintains information in the event of system failure Bring object to MM to be accessed Store logs and recovery points Write object back if modified 1/11/2017
  • 25. Prof. Dhaval R. Chandarana 25 •Principle: – Record all changes made to state of process (‘audit trail’ or ‘log’) such that process can be returned to a previous state – Example: A transaction based environment where transactions update a database • It is possible to commit or undo updates on a per-transaction basis • A commit indicates that the transaction on the object was successful and changes are permanent (1.a) Updating-in-place • Principle: every update (write) operation to an object creates a log in stable storage that can be used to ‘undo’ and ‘redo’ the operation • Log content: object name, old object state, new object state • Implementation of a recoverable update operation: – Do operation: update object and write log record – Undo operation: log(old) -> object (undoes the action performed by a do) – Redo operation: log(new) -> object (redoes the action performed by a do) – Display operation: display log record (optional) • Problem: a ‘do’ cannot be recovered if system crashes after write object but before log record write (1.b) The write-ahead log protocol • Principle: write log record before updating object (1) The Operation-based Approach 1/11/2017
  • 26. Prof. Dhaval R. Chandarana 26 •Principle: establish frequent ‘recovery points’ or ‘checkpoints’ saving the entire state of process •Actions: – ‘Checkpointing’ or ‘taking a checkpoint’: saving process state – ‘Rolling back’ a process: restoring a process to a prior state Note: A process should be rolled back to the most recent ‘recovery point’ to minimize the overhead and delays in the completion of the process •Shadow Pages: Special case of state-based approach – Only a part of the system state is saved to minimize recovery – When an object is modified, page containing object is first copied on stable storage (shadow page) – If process successfully commits: shadow page discarded and modified page is made part of the database – If process fails: shadow page used and the modified page discarded (2) State-based Approach 1/11/2017
  • 27. Recovery in concurrent systems • Issue: if one of a set of cooperating processes fails and has to be rolled back to a recovery point, all processes it communicated with since the recovery point have to be rolled back. • Conclusion: In concurrent and/or distributed systems all cooperating processes have to establish recovery points • Orphan messages and the domino effect – Case 1: failure of X after x3 : no impact on Y or Z – Case 2: failure of Y after sending msg. ‘m’ • Y rolled back to y2 • ‘m’ ≡ orphan massage • X rolled back to x2 – Case 3: failure of Z after z2 • Y has to roll back to y1 • X has to roll back to x1 Domino Effect • Z has to roll back to z1 X Y Z y1 x1 z1 z2 x2 y2 x3 m Time 1/11/2017 27Prof. Dhaval R. Chandarana
  • 28. Lost messages • Assume that x1 and y1 are the only recovery points for processes X and Y, respectively • Assume Y fails after receiving message ‘m’ • Y rolled back to y1,X rolled back to x1 • Message ‘m’ is lost Note: there is no distinction between this case and the case where message ‘m’ is lost in communication channel and processes X and Y are in states x1 and y1, respectively X Y y1 x1 m Time Failure 1/11/2017 28Prof. Dhaval R. Chandarana
  • 29. Log Based Recovery • When failures occur the following operation that use the log are executed. • UNDO: restore database to state prior to execution. • REDO: perform the changes to the database over again. 1/11/2017 29Prof. Dhaval R. Chandarana
  • 32. Write-Ahead Logging Protocol • write-ahead logging (WAL) is a family of techniques for providing atomicity and durability in database systems. • In a system using WAL, all modifications are written to a log before they are applied. Usually both redo and undo information is stored in the log. • The purpose of this can be illustrated by an example. Imagine a program that is in the middle of performing some operation when the machine it is running on loses power. Upon restart, that program might well need to know whether the operation it was performing succeeded, half-succeeded, or failed. If a write- ahead log is used, the program can check this log and compare what it was supposed to be doing when it unexpectedly lost power to what was actually done. On the basis of this comparison, the program could decide to undo what it had started, complete what it had started, or keep things as they are.1/11/2017 32Prof. Dhaval R. Chandarana
  • 33. Write-Ahead Logging Protocol 1/11/2017 33Prof. Dhaval R. Chandarana
  • 34. Advanced recovery techniques • Shadow Paging • Fuzzy checkpoint • ARIES • RAID levels 1/11/2017 34Prof. Dhaval R. Chandarana
  • 35. Shadow Paging • It is inconvenient to maintain logs of all transactions for the purposes of recovery. An alternative is to use a system of shadow paging. • This is where the database is divided into pages that may be stored in any order on the disk. • In order to identify the location of any given page, we use something called a page table. 1/11/2017 35Prof. Dhaval R. Chandarana
  • 36. Shadow Paging • During the life of a transaction two page tables are maintained, one called a shadow page table and current page table. • When a transaction begins both of these page tables point to the same locations (are identical). • However during the lifetime of a transaction changes may be made update values etc. So whenever we update a page in the database we always write the updated page to a new location. • This means that when we then update our current page table to reflect the changes that have been made. 1/11/2017 36Prof. Dhaval R. Chandarana
  • 37. Shadow Paging 1/11/2017 37Prof. Dhaval R. Chandarana
  • 38. Fuzzy checkpoint • In a fuzzy checkpoint, the database server does not flush the modified pages in the shared-memory buffer pool to disk for certain types of operations, called fuzzy operations. • When a fuzzy checkpoint completes, the pages might not be consistent with each other, because the database server does not flush all data pages to disk. • A fuzzy checkpoint completes much more quickly than a full checkpoint and reduces the amount of physical logging during heavy update activity. When necessary, the database server performs a full checkpoint to ensure the physical consistency of all data on disk. 1/11/2017 38Prof. Dhaval R. Chandarana
  • 39. Fuzzy checkpoint • Fuzzy Operations – Inserts – Updates – Deletes • Important: – Fuzzy checkpoints are disabled for the primary and secondary servers in a High-Availability Data Replication pair. 1/11/2017 39Prof. Dhaval R. Chandarana
  • 40. ARIES • In computer science, Algorithms for Recovery and Isolation Exploiting Semantics, or ARIES is a recovery algorithm designed to work with a no-force, steal database approach; it is used by IBM DB2, Microsoft SQL Server and many other database systems. 1/11/2017 40Prof. Dhaval R. Chandarana
  • 41. Principles lie behind ARIES • Three main principles lie behind ARIES • Write-ahead logging: Any change to an object is first recorded in the log, and the log must be written to stable storage before changes to the object are written to disk. • Repeating history during Redo: On restart after a crash, ARIES retraces the actions of a database before the crash and brings the system back to the exact state that it was in before the crash. Then it undoes the transactions still active at crash time. • Logging changes during Undo: Changes made to the database while undoing transactions are logged to ensure such an action isn't repeated in the event of repeated restarts. 1/11/2017 41Prof. Dhaval R. Chandarana
  • 42. ARIES LSN 1/11/2017 42Prof. Dhaval R. Chandarana
  • 43. RAID Level Redundant Array of Inexpensive Disks RAID Level 0 Striping RAID Level 1 Mirroring and performance improvements RAID Level 2 Byte-level parity RAID Level 3 Block-level parity RAID Level 4 Rotating parity RAID Level 5 Tolerates failure of two disk drives 1/11/2017 43Prof. Dhaval R. Chandarana
  • 44. RAID Level-0 file data block 1block 0 block 2 block 3 block 4 Disk 0 Disk 1 0 block 0 1 block 2 2 block 4 3 4 5 sectors 0 block 1 1 block 3 2 3 4 5 sectors 1/11/2017 44Prof. Dhaval R. Chandarana
  • 45. RAID Level-1 file data block 1block 0 block 2 block 3 block 4 Disk 0 Disk 1 0 block 0 1 block 1 2 block 2 3 block 3 4 block 4 5 sectors 0 block 0 1 block 1 2 block 2 3 block 3 4 block 4 5 sectors 1/11/2017 45Prof. Dhaval R. Chandarana
  • 46. RAID Level - 2 • RAID Level 2 uses concept of parallel access technique. It works on the word(byte) level. So each strip stores one bit. It takes data striping to the extreme, writing only 1 bit per strip, instead of in arbitrary size block. For this reason, it require a minimum, of 8 surface to write data to the hard disk. • In RAID level 2, strip are very small, so when a block is read, all disks are accessed in parallel. • Hamming code generation is time consuming, therefore RAID level 2 is too slow for most commercial application. 1/11/2017 46Prof. Dhaval R. Chandarana
  • 47. RAID Level - 2 Error Correction Code (ECC) 1/11/2017 47Prof. Dhaval R. Chandarana
  • 48. RAID Level - 3 1/11/2017 48Prof. Dhaval R. Chandarana
  • 49. RAID Level - 4 1/11/2017 49Prof. Dhaval R. Chandarana
  • 50. RAID Level - 5 1/11/2017 50Prof. Dhaval R. Chandarana
  • 51. RAID Level - 6 1/11/2017 51Prof. Dhaval R. Chandarana
  • 53. State Transitions in 2PC Protocol 1/11/2017 53Prof. Dhaval R. Chandarana
  • 54. Three Phase Commit Protocols 1/11/2017 54Prof. Dhaval R. Chandarana
  • 55. State Transitions in 3PC Protocol 1/11/2017 55Prof. Dhaval R. Chandarana