Docsity

Distributed DBMS Reliability-Distributed Database-Lecture 10 Slides-Computer Science, Appunti di Basi di Dati

Anteprima parziale del testo

Scarica Distributed DBMS Reliability-Distributed Database-Lecture 10 Slides-Computer Science e più Appunti in PDF di Basi di Dati solo su Docsity!

Chapter 10: Distributed DBMS Reliability

Definitions and Basic Concepts

Local Recovery Management

In-place update, out-of-place update

Distributed Reliability Protocols

Two phase commit protocol

Three phase commit protocol

Acknowledgements:

I am indebted to Arturas Mazeika for providing me his slides of this course.

J. Gamper

Reliability

A

reliable DDBMS

is one that can continue to process user requests even when the

underlying system is unreliable, i.e., failures occur

Failures

-

Transaction failures

System (site) failures, e.g., system crash, power supply failure

Media failures, e.g., hard disk failures

Communication failures, e.g., lost/undeliverable messages

Reliability is closely related to the problem of how to maintain the

atomicity

and

durability

properties of transactions

J. Gamper

Local Recovery Management

The

local recovery manager (LRM)

maintains the atomicity and durability properties of

local transactions at each site.

Architecture

- Volatile

storage: The main memory of the computer system (RAM)

- Stable

storage

A storage that “never” looses its contents

storage) and software (stable-write, stable-read, clean-up) componentsIn reality this can only be approximated by a combination of hardware (non-volatile

J. Gamper

Local Recovery Management...

Two ways for the LRM to deal with update/write operations

- In-place update

Physically changes the value of the data item in the stable database

As a result, previous values are lost

Mostly used in databases

- Out-of-place update

value(s)The new value(s) of updated data item(s) are stored separately from the old

Periodically, the updated values have to be integrated into the stable DB

J. Gamper

In-Place Update...

A

log

is the most popular structure for recording DB modifications on stable storage

Consists of a sequence of

log records

that record all the update activities in the DB

Each log record describes a significant event during transaction processing

Types of log records

-

< T

i

start

: if transaction

T

i

has started

< T

i

, X

j

, V

1

, V

2

: before

T

i

executes a

write

X

j

, where

V

1

is the old value

before the write and

V

2

is the new value after the write

< T

i

commit

: if

T

i

has committed

< T

i

abort

: if

T

i

has aborted

checkpoint

the DB in case of a failure.With the information in the log file the recovery manager can restore the consistency of

J. Gamper

In-Place Update...

Assume the following situation when a system crash occurs

Upon recovery:

-

All effects of transaction

T

1

should be reflected in the database (

REDO)

None of the effects of transaction

T

2

should be reflected in the database (

UNDO)

J. Gamper

In-Place Update...

UNDO Protocol

-

has startedUNDO’ing an action means to restore the object to its image before the transaction

The UNDO operation uses the log information and restores the old value of the object

J. Gamper

In-Place Update...

Example:

Consider the transactions

T

0

and

T

1

T

0

executes before

T

1

) and the

following initial values:

A

B

, and

C

T

0 :

read

A

A

A

write

A

read

B

B

B

write

( B ) T 1 :

read

C

C

C

write

C

Possible order of actual outputs to the log file and the DB:

Log

DB

< T

0

, start >

< T

0

, A,

< T

0

, B,

< T

0

, commit >

A

B

< T

1

, start >

< T

1

, C,

< T

1

, commit >

C

J. Gamper

In-Place Update...

Logging Interface

Log pages/buffers can be written to stable storage in two ways:

- synchronously

The addition of each log record requires that the log is written to stable storage

supended until the write is completeWhen the log is written synchronoously, the executtion of the transaction is

delay in response time

- asynchronously

Log is moved to stable storage either at periodic intervals or when the buffer fills up.

J. Gamper

In-Place Update...

When to write

log records into stable storage?

Assume a transaction

T

updates a page

P

Fortunate case

-

System writes

P

in stable database

System updates stable log for this update

SYSTEM FAILURE OCCURS!... (before

T

commits)

We can recover (undo) by restoring

P

to its old state by using the log

Unfortunate case

-

System writes

P

in stable database

SYSTEM FAILURE OCCURS!... (before stable log is updated)

valueWe cannot recover from this failure because there is no log record to restore the old

Solution: Write-Ahead Log (WAL) protocol

J. Gamper

Out-of-Place Update

Two out-of-place strategies are shadowing and differential files

Shadowing

-

the new values and write it into the stable databaseWhen an update occurs, don’t change the old page, but create a shadow page with

Update the access paths so that subsequent accesses are to the new shadow page

The old page is retained for recovery

Differential files

-

For each DB file

F

maintain

a read-only part

F R

a differential file consisting of insertions part (

DF

) and deletions part (

DF

−

Thus,

F

F R

DF

DF

−

J. Gamper

Distributed Reliability Protocols

and durability of distributed transactionsAs with local reliability protocols, the distributed versions aim to maintain the atomicity

recoveryMost problematic issues in a distributed transaction are commit, termination, and

- Commit protocols

How to execute a commit command for distributed transactions

How to ensure atomicity (and durability)?

- Termination protocols

If a failure occurs at a site, how can the other operational sites deal with it

Non-blocking:

the occurrence of failures should not force the sites to wait until the

failure is repaired to terminate the transaction

- Recovery protocols

When a failure occurs, how do the sites where the failure occurred deal with it

Independent:

a failed site can determine the outcome of a transaction without

having to obtain remote information

J. Gamper

Centralized Two Phase Commit Protocol (2PC)

Very simple protocol that ensures the atomic commitment of distributed transactions.

Phase 1:

The coordinator gets the participants ready to write the results into the

database

Phase 2:

Everybody writes the results into the database

Global Commit Rule

-

abort itThe coordinator aborts a transaction if and only if at least one participant votes to

commit itThe coordinator commits a transaction if and only if all of the participants vote to

Centralized

since communication is only between coordinator and the participants

J. Gamper

Centralized Two Phase Commit Protocol (2PC)...

J. Gamper