SlideShare a Scribd company logo
1 of 16
Log-Based Recovery
 A Log is the most widely used structure for recording database modifications.
 Update log record: It describes a single database write. It has following fields-
 Transaction identifier is the unique identifier of the transaction that performed the
write operation.
 Data item identifier is the unique identifier of the data item written.
 Old value is the value of the data item prior to the write.
 New value is the value of the data item that it will have after the write.
 Various types of log records are represented as:
 < Ti start>: Transaction Ti has started.
 <Ti, X, V1, V2> : Transaction Ti has performed a write on data item Xj , Xj had
value v1 before the write, and will have value v2 after the write.
 <Ti commit> : Transaction Ti has committed.
 <Ti abort> : Transaction Ti has aborted.
 Two techniques that user s log:
 Deferred database modification
 Immediate database modification
Deferred Database Modification
 The deferred database modification scheme records all
modifications to the log, but defers all the writes to after
partial commit.
 Assume that transactions execute serially
 Transaction starts by writing <Ti start> record to log.
 A write(X) operation results in a log record <Ti, X, V>
being written, where V is the new value for X
 Note: old value is not needed for this scheme
 The write is not performed on X at this time, but is
deferred.
 When Ti partially commits, <Ti commit> is written to the
log
 Finally, the log records are read and used to actually
execute the previously deferred writes.
Deferred Database Modification
(Cont.)
 During recovery after a crash, a transaction needs to be
redone if and only if both <Ti start> and<Ti commit>
are there in the log.
 Redoing a transaction Ti ( redoTi) sets the value of all
data items updated by the transaction to the new values.
 Crashes can occur while
 the transaction is executing the original updates, or
 while recovery action is being taken
 example transactions T0 and T1 (T0 executes before T1):
T0: read (A) T1 : read (C);
A: = A – 50; C:-=C- 100;
Write (A); write (C);
read (B);
B:= B + 50;
write (B);
Deferred Database Modification
(Cont.)
 Below we show the log as it appears at three instances of
time.
 If log on stable storage at time of crash is as in case:
(a) No redo actions need to be taken
(b) redo(T0) must be performed since <T0 commit> is present
(c) redo(T0) must be performed followed by redo(T1) since
<T0 commit> and <Ti commit> are present
Immediate Database Modification
 The immediate database modification technique allows
database modifications to be output to the database while
the transaction is still in the active state.
 Update log record must be written before database item is
written
 We assume that the log record is output directly to stable storage
 Can be extended to postpone log record output, so long as prior to execution of
an output(B) operation for a data block B, all log records corresponding to
items B must be flushed to stable storage
 Output of updated blocks can take place at any time before
or after transaction commit
 Order in which blocks are output can be different from the
order in which they are written.
Immediate Database Modification Example
Log Write Output
<T0 start>
<T0, A, 1000, 950>
To, B, 2000, 2050
A = 950
B = 2050
<T0 commit>
<T1 start>
<T1, C, 700, 600>
C = 600
BB, BC
<T1 commit>
BA
 Note: BX denotes block containing X.
x1
Immediate Database Modification
(Cont.)
 Recovery procedure has two operations instead of one:
 undo(Ti) restores the value of all data items updated by Ti to their old
values, going backwards from the last log record for Ti
 redo(Ti) sets the value of all data items updated by Ti to the new values,
going forward from the first log record for Ti
 Both operations must be idempotent
 That is, even if the operation is executed multiple times the effect is the
same as if it is executed once
 Needed since operations may get re-executed during recovery
 When recovering after failure:
 Transaction Ti needs to be undone if the log contains the record
<Ti start>, but does not contain the record <Ti commit>.
 Transaction Ti needs to be redone if the log contains both the record <Ti
start> and the record <Ti commit>.
 Undo operations are performed first, then redo
operations.
Immediate DB Modification Recovery Example
Below we show the log as it appears at three instances of time.
Recovery actions in each case above are:
(a) undo (T0): B is restored to 2000 and A to 1000.
(b) undo (T1) and redo (T0): C is restored to 700, and then A and B are
set to 950 and 2050 respectively.
(c) redo (T0) and redo (T1): A and B are set to 950 and 2050
respectively. Then C is set to 600
Recovery With Concurrent
Transactions
 We modify the log-based recovery schemes to allow multiple transactions to
execute concurrently.
 All transactions share a single disk buffer and a single log
 A buffer block can have data items updated by one or more transactions
 We assume concurrency control using strict two-phase locking;
 i.e. the updates of uncommitted transactions should not be visible to other
transactions
 Otherwise how to perform undo if T1 updates A, then T2 updates A and
commits, and finally T1 has to abort?
 Logging is done as described earlier.
 Log records of different transactions may be interspersed in the log.
 The checkpointing technique and actions taken on recovery have to be
changed
 since several transactions may be active when a checkpoint is performed.
Recovery With Concurrent Transactions (Cont.)
 Checkpoints are performed as before, except that the
checkpoint log record is now of the form
< checkpoint L>
where L is the list of transactions active at the time of
the checkpoint
 We assume no updates are in progress while the checkpoint is carried out
(will relax this later)
 When the system recovers from a crash, it first does
the following:
1. Initialize undo-list and redo-list to empty
2. Scan the log backwards from the end, stopping when the first
<checkpoint L> record is found.
For each record found during the backward scan:
 if the record is <Ti commit>, add Ti to redo-list
 if the record is <Ti start>, then if Ti is not in redo-list, add Ti to undo-
list
3. For every Ti in L, if Ti is not in redo-list, add Ti to undo-list
Recovery With Concurrent Transactions (Cont.)
 At this point undo-list consists of incomplete
transactions which must be undone, and redo-list
consists of finished transactions that must be redone.
 Recovery now continues as follows:
1. Scan log backwards from most recent record, stopping when
<Ti start> records have been encountered for every Ti in undo-list.
 During the scan, perform undo for each log record that belongs to a
transaction in undo-list.
2. Locate the most recent <checkpoint L> record.
3. Scan log forwards from the <checkpoint L> record till the end of the log.
 During the scan, perform redo for each log record that belongs to a
transaction on redo-list
Example of Recovery
 Go over the steps of the recovery algorithm on the
following log:
<T0 start>
<T0, A, 0, 10>
<T0 commit>
<T1 start>
<T1, B, 0, 10>
<T2 start> /* Scan in Step 4 stops here */
<T2, C, 0, 10>
<T2, C, 10, 20>
<checkpoint {T1, T2}>
<T3 start>
<T3, A, 10, 20>
<T3, D, 0, 10>
<T3 commit>
Log based and Recovery with concurrent transaction

More Related Content

What's hot

12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbmsNancy Gulati
 
Indexing and Hashing
Indexing and HashingIndexing and Hashing
Indexing and Hashingsathish sak
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and propertiesChetan Mahawar
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency controlDhani Ahmad
 
File organization 1
File organization 1File organization 1
File organization 1Rupali Rana
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMSkoolkampus
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency ControlDilum Bandara
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocolsChethanMp7
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)Ravinder Kamboj
 
Time space trade off
Time space trade offTime space trade off
Time space trade offanisha talwar
 

What's hot (20)

12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 
Indexing and Hashing
Indexing and HashingIndexing and Hashing
Indexing and Hashing
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
Shadow paging
Shadow pagingShadow paging
Shadow paging
 
Recovery techniques
Recovery techniquesRecovery techniques
Recovery techniques
 
File organization 1
File organization 1File organization 1
File organization 1
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Disk structure
Disk structureDisk structure
Disk structure
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
 
File allocation methods (1)
File allocation methods (1)File allocation methods (1)
File allocation methods (1)
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Time space trade off
Time space trade offTime space trade off
Time space trade off
 

Viewers also liked

Best practices for DB2 for z/OS log based recovery
Best practices for DB2 for z/OS log based recoveryBest practices for DB2 for z/OS log based recovery
Best practices for DB2 for z/OS log based recoveryFlorence Dubois
 
Understanding and controlling transaction logs
Understanding and controlling transaction logsUnderstanding and controlling transaction logs
Understanding and controlling transaction logsRed Gate Software
 
03 Data Recovery - Notes
03 Data Recovery - Notes03 Data Recovery - Notes
03 Data Recovery - NotesKranthi
 
Db2 zos-sharing
Db2 zos-sharingDb2 zos-sharing
Db2 zos-sharingwetwind55
 
2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_logHVR Software
 
Load Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed DatabaseLoad Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed DatabaseMd. Shamsur Rahim
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recoveryimranasayed
 
Database ,14 Parallel DBMS
Database ,14 Parallel DBMSDatabase ,14 Parallel DBMS
Database ,14 Parallel DBMSAli Usman
 
20. Parallel Databases in DBMS
20. Parallel Databases in DBMS20. Parallel Databases in DBMS
20. Parallel Databases in DBMSkoolkampus
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMSkoolkampus
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMSkoolkampus
 
Disaster recovery and the cloud
Disaster recovery and the cloudDisaster recovery and the cloud
Disaster recovery and the cloudJason Dea
 

Viewers also liked (20)

Database recovery
Database recoveryDatabase recovery
Database recovery
 
Best practices for DB2 for z/OS log based recovery
Best practices for DB2 for z/OS log based recoveryBest practices for DB2 for z/OS log based recovery
Best practices for DB2 for z/OS log based recovery
 
Understanding and controlling transaction logs
Understanding and controlling transaction logsUnderstanding and controlling transaction logs
Understanding and controlling transaction logs
 
03 Data Recovery - Notes
03 Data Recovery - Notes03 Data Recovery - Notes
03 Data Recovery - Notes
 
Data recovery
Data recoveryData recovery
Data recovery
 
Unit07 dbms
Unit07 dbmsUnit07 dbms
Unit07 dbms
 
Db2 zos-sharing
Db2 zos-sharingDb2 zos-sharing
Db2 zos-sharing
 
2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log
 
Load Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed DatabaseLoad Balancing in Parallel and Distributed Database
Load Balancing in Parallel and Distributed Database
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
 
Database ,14 Parallel DBMS
Database ,14 Parallel DBMSDatabase ,14 Parallel DBMS
Database ,14 Parallel DBMS
 
Database and different types of databases available in market
Database and different types of databases available in marketDatabase and different types of databases available in market
Database and different types of databases available in market
 
Disaster Recovery in the Cloud
Disaster Recovery in the CloudDisaster Recovery in the Cloud
Disaster Recovery in the Cloud
 
Field study 1
Field study 1Field study 1
Field study 1
 
Data recovery
Data recoveryData recovery
Data recovery
 
Data recovery
Data recoveryData recovery
Data recovery
 
20. Parallel Databases in DBMS
20. Parallel Databases in DBMS20. Parallel Databases in DBMS
20. Parallel Databases in DBMS
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
 
Disaster recovery and the cloud
Disaster recovery and the cloudDisaster recovery and the cloud
Disaster recovery and the cloud
 

Similar to Log based and Recovery with concurrent transaction

DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptxDBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptxHemaSenthil5
 
Recovery & Atom city & Log based Recovery
Recovery & Atom city & Log based RecoveryRecovery & Atom city & Log based Recovery
Recovery & Atom city & Log based RecoveryMeghaj Mallick
 
Recovery System.pptx
Recovery System.pptxRecovery System.pptx
Recovery System.pptxssuserfb9a21
 
Recovery system
Recovery systemRecovery system
Recovery systemRakesh S
 
recovery system
recovery systemrecovery system
recovery systemshreeuva
 
Recovery with concurrent transaction
Recovery with concurrent transactionRecovery with concurrent transaction
Recovery with concurrent transactionlavanya marichamy
 
CS 542 -- Failure Recovery, Concurrency Control
CS 542 -- Failure Recovery, Concurrency ControlCS 542 -- Failure Recovery, Concurrency Control
CS 542 -- Failure Recovery, Concurrency ControlJ Singh
 
Lesson12 recovery architectures
Lesson12 recovery architecturesLesson12 recovery architectures
Lesson12 recovery architecturesRaval Vijay
 
database1.pptx
database1.pptxdatabase1.pptx
database1.pptxOmarKamil1
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management Systemsweetysweety8
 
Introduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryZainab Almugbel
 
Databases: Backup and Recovery
Databases: Backup and RecoveryDatabases: Backup and Recovery
Databases: Backup and RecoveryDamian T. Gordon
 

Similar to Log based and Recovery with concurrent transaction (20)

Assignment#13
Assignment#13Assignment#13
Assignment#13
 
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptxDBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
 
Recovery system
Recovery systemRecovery system
Recovery system
 
DBMS UNIT 5 CHAPTER 3.ppt
DBMS UNIT 5 CHAPTER 3.pptDBMS UNIT 5 CHAPTER 3.ppt
DBMS UNIT 5 CHAPTER 3.ppt
 
Recovery & Atom city & Log based Recovery
Recovery & Atom city & Log based RecoveryRecovery & Atom city & Log based Recovery
Recovery & Atom city & Log based Recovery
 
Unit 07 dbms
Unit 07 dbmsUnit 07 dbms
Unit 07 dbms
 
Recovery System.pptx
Recovery System.pptxRecovery System.pptx
Recovery System.pptx
 
Recovery system
Recovery systemRecovery system
Recovery system
 
Assignment#14
Assignment#14Assignment#14
Assignment#14
 
17 Recovery system.ppt
17 Recovery system.ppt17 Recovery system.ppt
17 Recovery system.ppt
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
 
recovery system
recovery systemrecovery system
recovery system
 
Dbms
DbmsDbms
Dbms
 
Recovery with concurrent transaction
Recovery with concurrent transactionRecovery with concurrent transaction
Recovery with concurrent transaction
 
CS 542 -- Failure Recovery, Concurrency Control
CS 542 -- Failure Recovery, Concurrency ControlCS 542 -- Failure Recovery, Concurrency Control
CS 542 -- Failure Recovery, Concurrency Control
 
Lesson12 recovery architectures
Lesson12 recovery architecturesLesson12 recovery architectures
Lesson12 recovery architectures
 
database1.pptx
database1.pptxdatabase1.pptx
database1.pptx
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Introduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theory
 
Databases: Backup and Recovery
Databases: Backup and RecoveryDatabases: Backup and Recovery
Databases: Backup and Recovery
 

Recently uploaded

Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...Health
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 

Recently uploaded (20)

Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 

Log based and Recovery with concurrent transaction

  • 1.
  • 2.
  • 3. Log-Based Recovery  A Log is the most widely used structure for recording database modifications.  Update log record: It describes a single database write. It has following fields-  Transaction identifier is the unique identifier of the transaction that performed the write operation.  Data item identifier is the unique identifier of the data item written.  Old value is the value of the data item prior to the write.  New value is the value of the data item that it will have after the write.  Various types of log records are represented as:  < Ti start>: Transaction Ti has started.  <Ti, X, V1, V2> : Transaction Ti has performed a write on data item Xj , Xj had value v1 before the write, and will have value v2 after the write.  <Ti commit> : Transaction Ti has committed.  <Ti abort> : Transaction Ti has aborted.  Two techniques that user s log:  Deferred database modification  Immediate database modification
  • 4. Deferred Database Modification  The deferred database modification scheme records all modifications to the log, but defers all the writes to after partial commit.  Assume that transactions execute serially  Transaction starts by writing <Ti start> record to log.  A write(X) operation results in a log record <Ti, X, V> being written, where V is the new value for X  Note: old value is not needed for this scheme  The write is not performed on X at this time, but is deferred.  When Ti partially commits, <Ti commit> is written to the log  Finally, the log records are read and used to actually execute the previously deferred writes.
  • 5. Deferred Database Modification (Cont.)  During recovery after a crash, a transaction needs to be redone if and only if both <Ti start> and<Ti commit> are there in the log.  Redoing a transaction Ti ( redoTi) sets the value of all data items updated by the transaction to the new values.  Crashes can occur while  the transaction is executing the original updates, or  while recovery action is being taken  example transactions T0 and T1 (T0 executes before T1): T0: read (A) T1 : read (C); A: = A – 50; C:-=C- 100; Write (A); write (C); read (B); B:= B + 50; write (B);
  • 6. Deferred Database Modification (Cont.)  Below we show the log as it appears at three instances of time.  If log on stable storage at time of crash is as in case: (a) No redo actions need to be taken (b) redo(T0) must be performed since <T0 commit> is present (c) redo(T0) must be performed followed by redo(T1) since <T0 commit> and <Ti commit> are present
  • 7. Immediate Database Modification  The immediate database modification technique allows database modifications to be output to the database while the transaction is still in the active state.  Update log record must be written before database item is written  We assume that the log record is output directly to stable storage  Can be extended to postpone log record output, so long as prior to execution of an output(B) operation for a data block B, all log records corresponding to items B must be flushed to stable storage  Output of updated blocks can take place at any time before or after transaction commit  Order in which blocks are output can be different from the order in which they are written.
  • 8. Immediate Database Modification Example Log Write Output <T0 start> <T0, A, 1000, 950> To, B, 2000, 2050 A = 950 B = 2050 <T0 commit> <T1 start> <T1, C, 700, 600> C = 600 BB, BC <T1 commit> BA  Note: BX denotes block containing X. x1
  • 9. Immediate Database Modification (Cont.)  Recovery procedure has two operations instead of one:  undo(Ti) restores the value of all data items updated by Ti to their old values, going backwards from the last log record for Ti  redo(Ti) sets the value of all data items updated by Ti to the new values, going forward from the first log record for Ti  Both operations must be idempotent  That is, even if the operation is executed multiple times the effect is the same as if it is executed once  Needed since operations may get re-executed during recovery  When recovering after failure:  Transaction Ti needs to be undone if the log contains the record <Ti start>, but does not contain the record <Ti commit>.  Transaction Ti needs to be redone if the log contains both the record <Ti start> and the record <Ti commit>.  Undo operations are performed first, then redo operations.
  • 10. Immediate DB Modification Recovery Example Below we show the log as it appears at three instances of time. Recovery actions in each case above are: (a) undo (T0): B is restored to 2000 and A to 1000. (b) undo (T1) and redo (T0): C is restored to 700, and then A and B are set to 950 and 2050 respectively. (c) redo (T0) and redo (T1): A and B are set to 950 and 2050 respectively. Then C is set to 600
  • 11.
  • 12. Recovery With Concurrent Transactions  We modify the log-based recovery schemes to allow multiple transactions to execute concurrently.  All transactions share a single disk buffer and a single log  A buffer block can have data items updated by one or more transactions  We assume concurrency control using strict two-phase locking;  i.e. the updates of uncommitted transactions should not be visible to other transactions  Otherwise how to perform undo if T1 updates A, then T2 updates A and commits, and finally T1 has to abort?  Logging is done as described earlier.  Log records of different transactions may be interspersed in the log.  The checkpointing technique and actions taken on recovery have to be changed  since several transactions may be active when a checkpoint is performed.
  • 13. Recovery With Concurrent Transactions (Cont.)  Checkpoints are performed as before, except that the checkpoint log record is now of the form < checkpoint L> where L is the list of transactions active at the time of the checkpoint  We assume no updates are in progress while the checkpoint is carried out (will relax this later)  When the system recovers from a crash, it first does the following: 1. Initialize undo-list and redo-list to empty 2. Scan the log backwards from the end, stopping when the first <checkpoint L> record is found. For each record found during the backward scan:  if the record is <Ti commit>, add Ti to redo-list  if the record is <Ti start>, then if Ti is not in redo-list, add Ti to undo- list 3. For every Ti in L, if Ti is not in redo-list, add Ti to undo-list
  • 14. Recovery With Concurrent Transactions (Cont.)  At this point undo-list consists of incomplete transactions which must be undone, and redo-list consists of finished transactions that must be redone.  Recovery now continues as follows: 1. Scan log backwards from most recent record, stopping when <Ti start> records have been encountered for every Ti in undo-list.  During the scan, perform undo for each log record that belongs to a transaction in undo-list. 2. Locate the most recent <checkpoint L> record. 3. Scan log forwards from the <checkpoint L> record till the end of the log.  During the scan, perform redo for each log record that belongs to a transaction on redo-list
  • 15. Example of Recovery  Go over the steps of the recovery algorithm on the following log: <T0 start> <T0, A, 0, 10> <T0 commit> <T1 start> <T1, B, 0, 10> <T2 start> /* Scan in Step 4 stops here */ <T2, C, 0, 10> <T2, C, 10, 20> <checkpoint {T1, T2}> <T3 start> <T3, A, 10, 20> <T3, D, 0, 10> <T3 commit>