SlideShare a Scribd company logo
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

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
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
ChethanMp7
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
Bansari Shah
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 
Crash recovery in database
Crash recovery in databaseCrash recovery in database
Crash recovery in database
Prof.Nilesh Magar
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
Kalaimathi Vijayakumar
 
Tree pruning
 Tree pruning Tree pruning
Tree pruning
Shivangi Gupta
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
Dattatray Gandhmal
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
Chetan Mahawar
 
Serializability
SerializabilitySerializability
Serializability
Pyingkodi Maran
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
Saranya Natarajan
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
Kuppusamy P
 
Transaction management in DBMS
Transaction management in DBMSTransaction management in DBMS
Transaction management in DBMS
Megha Sharma
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
Vardhil Patel
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
Ravinder Kamboj
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
GirdharRatne
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Akhil Kaushik
 

What's hot (20)

Semaphores
SemaphoresSemaphores
Semaphores
 
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
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Crash recovery in database
Crash recovery in databaseCrash recovery in database
Crash recovery in database
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
Tree pruning
 Tree pruning Tree pruning
Tree pruning
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
B trees dbms
B trees dbmsB trees dbms
B trees dbms
 
Serializability
SerializabilitySerializability
Serializability
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Transaction management in DBMS
Transaction management in DBMSTransaction management in DBMS
Transaction management in DBMS
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 

Viewers also liked

database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 
Database recovery techniques
Database recovery techniquesDatabase recovery techniques
Database recovery techniques
pusp220
 
Database recovery
Database recoveryDatabase recovery
Database recovery
Vritti Malhotra
 
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
Florence Dubois
 
Understanding and controlling transaction logs
Understanding and controlling transaction logsUnderstanding and controlling transaction logs
Understanding and controlling transaction logs
Red Gate Software
 
03 Data Recovery - Notes
03 Data Recovery - Notes03 Data Recovery - Notes
03 Data Recovery - NotesKranthi
 
Data recovery
Data recoveryData recovery
Data recovery
Abhinav Parihar
 
Db2 zos-sharing
Db2 zos-sharingDb2 zos-sharing
Db2 zos-sharing
wetwind55
 
2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log
HVR 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 Database
Md. 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
 
Disaster Recovery in the Cloud
Disaster Recovery in the CloudDisaster Recovery in the Cloud
Disaster Recovery in the Cloud
Amazon Web Services
 
Data recovery
Data recoveryData recovery
Data recovery
Suresh Hirpara
 
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
 

Viewers also liked (20)

database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
Database recovery techniques
Database recovery techniquesDatabase recovery techniques
Database recovery techniques
 
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
 

Similar to Log based and Recovery with concurrent transaction

Assignment#13
Assignment#13Assignment#13
Assignment#13
Sunita Milind Dol
 
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptxDBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
HemaSenthil5
 
Recovery system
Recovery systemRecovery system
Recovery system
lalithambiga kamaraj
 
DBMS UNIT 5 CHAPTER 3.ppt
DBMS UNIT 5 CHAPTER 3.pptDBMS UNIT 5 CHAPTER 3.ppt
DBMS UNIT 5 CHAPTER 3.ppt
HemakanisiriA3124
 
Recovery & Atom city & Log based Recovery
Recovery & Atom city & Log based RecoveryRecovery & Atom city & Log based Recovery
Recovery & Atom city & Log based Recovery
Meghaj Mallick
 
Recovery System.pptx
Recovery System.pptxRecovery System.pptx
Recovery System.pptx
ssuserfb9a21
 
Recovery system
Recovery systemRecovery system
Recovery system
Rakesh S
 
Assignment#14
Assignment#14Assignment#14
Assignment#14
Sunita Milind Dol
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
NIVETHA37590
 
recovery system
recovery systemrecovery system
recovery system
shreeuva
 
Dbms
DbmsDbms
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 architectures
Raval Vijay
 
database1.pptx
database1.pptxdatabase1.pptx
database1.pptx
OmarKamil1
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
sweetysweety8
 
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
Zainab Almugbel
 
Databases: Backup and Recovery
Databases: Backup and RecoveryDatabases: Backup and Recovery
Databases: Backup and RecoveryDamian T. Gordon
 
DBMS LAB PPT.pptx on database managment st
DBMS LAB PPT.pptx on database managment stDBMS LAB PPT.pptx on database managment st
DBMS LAB PPT.pptx on database managment st
SaikiranBiradar3
 

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
 
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
 
DBMS LAB PPT.pptx on database managment st
DBMS LAB PPT.pptx on database managment stDBMS LAB PPT.pptx on database managment st
DBMS LAB PPT.pptx on database managment st
 

Recently uploaded

The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 

Recently uploaded (20)

The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 

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>