• No results found

2 nd Semester 2008/2009

N/A
N/A
Protected

Academic year: 2021

Share "2 nd Semester 2008/2009"

Copied!
113
0
0

Loading.... (view fulltext now)

Full text

(1)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Administra¸c˜ao e Optimiza¸c˜ao de Bases de Dados

Chapter 17: Recovery System

Departamento de Engenharia Inform´atica Instituto Superior T´ecnico

2nd Semester 2008/2009

Slides baseados nos slides oficiais do livro

“Database System Concepts”

(2)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Outline

1

Concepts

2

Log-Based Recovery

3

Concurrent Transactions

4

Buffering

5

The ARIES Algorithm

(3)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Outline

1

Concepts

2

Log-Based Recovery

3

Concurrent Transactions

4

Buffering

5

The ARIES Algorithm

(4)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Failure Classification

Transaction failure:

Logical errors: transaction cannot complete due to some internal error condition

System errors: the database system must terminate an active transaction due to an error condition (e.g., deadlock)

System crash: a power failure or other hardware or software failure causes the system to crash

Fail-stop assumption: non-volatile storage contents are assumed to not be corrupted by system crash

Database systems have numerous integrity checks to prevent corruption of disk data

Disk failure: a head crash or similar disk failure destroys all or part of disk storage

Destruction is assumed to be detectable: disk drives use checksums to detect failures

(5)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Recovery Algorithms

Recovery algorithms are techniques to ensure database consistency and transaction atomicity and durability despite failures

Recovery algorithms have two parts:

1 Actions taken during normal transaction processing to ensure enough information exists to recover from failures

2 Actions taken after a failure to recover the database contents to a state that ensures atomicity, consistency and durability

(6)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Storage Structure

Volatile storage:

does not survive system crashes

examples: main memory, cache memory

Nonvolatile storage:

survives system crashes

examples: disk, tape, flash memory, non-volatile (battery backed up) RAM

Stable storage:

a mythical form of storage that survives all failures approximated by maintaining multiple copies on distinct nonvolatile media

(7)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Data Access

Physical blocks: blocks residing on the disk

Buffer blocks: blocks residing temporarily in main memory Block movements between disk and main memory are initiated through the following two operations:

input(B)transfers the physical block B to main memory output(B)transfers the buffer block B to the disk, and replaces the appropriate physical block there

Each transaction T

i

has its private work-area in which local copies of all data items accessed and updated by it are kept

Ti’s local copy of a data item X is called xi

We assume, for simplicity, that each data item fits in, and is stored inside, a single block

(8)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Data Access (cont.)

Transaction transfers data items between system buffer blocks and its private work-area using the following operations:

read(X )assigns the value of data item X to the local variable xi

write(X )assigns the value of local variable xi to data item X in the buffer block

both these commands may necessitate the issue of an input(BX) instruction before the assignment, if the block BX in which X resides is not already in memory

output(B

X

) need not immediately follow write(X )

System can perform the output operation when it deems fit

(9)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Data Access

(10)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Recovery and Atomicity

Modifying the database without ensuring that the transaction will commit may leave the database in an inconsistent state

Consider transaction Ti that transfers 50$ from account A to account B

Several output operations may be required for Ti— a failure may occur after one of these modifications have been made but before all of them are made

To ensure atomicity despite failures, we first output information describing the modifications to stable storage without modifying the database itself

Two common approaches:

log-based recovery shadow-paging

We assume (initially) that transactions run serially, that is, one after the other.

(11)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Outline

1

Concepts

2

Log-Based Recovery Deferred Modification Immediate Modification Checkpoints

3

Concurrent Transactions

4

Buffering

5

The ARIES Algorithm

(12)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Log-Based Recovery

A log is kept on stable storage

The log is a sequence of log records, and maintains a record of update activities on the database

We assume for now that log records are written directly to stable storage (that is, they are not buffered)

Two approaches using logs:

Deferred database modification Immediate database modification

(13)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Log Records

When transaction T

i

starts, it registers itself by writing a record

< T

i

, start >

Before T

i

executes write(X ), a log record

< T

i

, X , V

1

, V

2

>

is written, where V

1

is the value of X before the write, and V

2

is the value to be written to X

When T

i

finishes its last statement, the log record

< T

i

, commit >

is written

(14)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

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

(15)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Transaction Recovery

During recovery, a transaction needs to be redone if and only if both < T

i

, start > and < T

i

, commit > are in the log

Redoing a transaction T

i

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 while recovery action is being taken

(16)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

(17)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,950 >

(18)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

(19)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

system failure!

No redo actions need to be taken

(20)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

<T0,commit >

(21)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

<T0,commit >

<T1,start >

(22)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

<T0,commit >

<T1,start >

<T1,C ,600 >

(23)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

<T0,commit >

<T1,start >

<T1,C ,600 >

system failure!

redo(T

0

) must be performed since

< T

0

, commit > is present

(24)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

<T0,commit >

<T1,start >

<T1,C ,600 >

<T1,commit >

(25)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,950 >

<T0,B,2050 >

<T0,commit >

<T1,start >

<T1,C ,600 >

<T1,commit >

system failure!

redo(T

0

) must be performed, followed by redo(T

1

) since < T

0

, commit > and

< T , commit > are present

(26)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Immediate Database Modification

The immediate database modification scheme allows database updates of an uncommitted transaction to be made as the writes are issued

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.

(27)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Transaction Recovery

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 (even if the

operation is executed multiple times the effect is the same as if it is executed once)

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

(28)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

(29)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,1000, 950 >

(30)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

(31)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

system failure!

undo(T

0

): B is restored to 2000 and A to

1000

(32)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

<T0,commit >

(33)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

<T0,commit >

<T1,start >

(34)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

<T0,commit >

<T1,start >

<T1,C ,700, 600 >

(35)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

<T0,commit >

<T1,start >

<T1,C ,700, 600 >

system failure!

undo(T

1

) and redo(T

0

): C is restored to 700, and then A and B are set to 950 and

2050 respectively

(36)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

<T0,commit >

<T1,start >

<T1,C ,700, 600 >

<T1,commit >

(37)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

An Example

T0: read(A) A:= A − 50 write(A) read(B) B:= B + 50 write(B)

T1: read(C ) C:= C − 100 write(C )

Log

<T0,start >

<T0,A,1000, 950 >

<T0,B,2000, 2050 >

<T0,commit >

<T1,start >

<T1,C ,700, 600 >

<T1,commit >

system failure!

redo(T

0

) and redo(T

1

): A and B are set to 950 and 2050, respectively, then C is set to

600

(38)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Checkpoints

Problems in recovery procedure:

searching the entire log is time-consuming

we might unnecessarily redo transactions which have already output their updates to the database.

Streamline recovery procedure by periodically performing checkpointing

Output all log records currently residing in main memory onto stable storage

Output all modified buffer blocks to the disk

Write a log record < checkpoint > onto stable storage

(39)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Recovery using Checkpoints

During recovery we need to consider only the most recent transaction T

i

that started before the checkpoint, and transactions that started after T

i

1 Scan backwards from end of log to find the most recent

<checkpoint >record

2 Continue scanning backwards till a record < Ti,start >is found

Need only consider the part of log following this record;

earlier part of log can be ignored, and can be erased whenever desired

3 For all transactions starting from Ti or later with no

<Ti,commit >, execute undo(Ti)

Done only in case of immediate modification

4 Scanning forward in the log, for all transactions starting from T or later with a < T,commit >, execute redo(T)

(40)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Deferred Modification Immediate Modification Checkpoints Concurrent Transactions Buffering The ARIES Algorithm

Checkpointing Example

time

checkpoint system failure

T1

T2

T3

T4

T

1

can be ignored (updates already output to disk) T

4

undone

T

2

and T

3

redone

(41)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Outline

1

Concepts

2

Log-Based Recovery

3

Concurrent Transactions

4

Buffering

5

The ARIES Algorithm

(42)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

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 T1updates A, then T2

updates A and finally T1has to abort?

Logging is done as described earlier

Log records of different transactions may be interspersed in the log

(43)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Checkpointing

The checkpointing technique and actions taken on recovery have to be changed since several transactions may be active when a checkpoint is performed

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

For now we assume no updates are in progress while the checkpoint is carried out

(44)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Restart Recovery

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

3 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

4 For every Ti in L, if Ti is not in redo-list, add Ti to undo-list

(45)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Redoing and Undoing

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

(46)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(47)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list T

3

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(48)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list T

3

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(49)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list T

3

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(50)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(51)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(52)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(53)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(54)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 10

(55)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 0

(56)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 0

(57)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 0

(58)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 0

(59)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 0

(60)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 20 10 0

(61)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 10 10 0

(62)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

<T3,commit >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 0 10 0

(63)

Administra¸ao e Optimiza¸ao de Bases de

Dados

Concepts Log-Based Recovery

Concurrent Transactions Buffering The ARIES Algorithm

Example of Recovery

Log

<T0,start >

<T0,A,0, 10 >

<T0,commit >

<T1,start >

<T1,B,0, 10 >

<T2,start >

<T2,C ,0, 10 >

<T2,C ,10, 20 >

<checkpoint{T1,T2} >

<T3,start >

<T3,A,10, 20 >

<T4,start >

<T3,D,0, 10 >

<T4,E ,0, 10 >

1

Scan log backwards

2

Perform undo

3

Perform redo

redo-list undo-list

T

3

T

4

T

1

T

2

A B C D E

initial values 0 0 0 0 0

current value 20 10 0 10 0

References

Related documents

On the other hand the size distribution of culturable bacteria and mould in kitchens and living rooms for type III residences with visible mould depicted the

Read each paragraph. Notice that these paragraphs do not include enough specific supporting details to make them effective. On another paper, REvISE each paragraph by asking

– Immediate release: Modification of inventory via basis adjustment – Delayed release: PnL recognition when hedge asset affects PnL  Back-testing of exposure to validate

– Multiple payments are allowed for single or multiple conditions – Cover is selected for Severity levels A-D (100%, 75%, 50%, 25%). or

We define a parser as a function that maps each source string, finite set of CFG rules, and start symbol to a set of syntax trees (usually, a null set or singleton set); and

The United States Government and a Georgia Whistleblower Reach a Historic False Claims Act and Stark Settlement Against Memorial Health University Medical Center, the Georgia

med kylling, bacon, brie, tomat, rødløk, aioli og pommes frites Dickens Sandwich with chicken, bacon, brie, tomato, onion, aioli and French fries Dickens Burger 179,-. med

Architecture may be said to be central to the enactment of Plessner’s philosophical anthropology as it simultaneously acts in the inner, outer and with-worlds, with the architect