• Tidak ada hasil yang ditemukan

Slides for Chapter 14: Distributed transactions - Chapter 14 slides

N/A
N/A
Protected

Academic year: 2019

Membagikan "Slides for Chapter 14: Distributed transactions - Chapter 14 slides"

Copied!
24
0
0

Teks penuh

(1)

Slides for Chapter 14:

Distributed transactions

From

Coulouris, Dollimore and Kindberg

Distributed Systems:

Concepts and Design

(2)

Figure 14.1

Distributed transactions

(a) Flat transaction

(b) Nested transactions

(3)

Figure 14.2

Nested banking transaction

a.withdraw(10)

.

b.withdraw(20)

Client

A

B

T

1

T

2

T

X

Y

Z

T

=

openTransaction

openSubTransaction

a.withdraw(10);

openSubTransaction

(4)

Figure 14.3

A distributed banking transaction

..

T

=

openTransaction

a.withdraw(4);

c.deposit(4);

b.withdraw(3);

d.deposit(3);

closeTransaction

(5)

Figure 14.4

Operations for two-phase commit protocol

canCommit?(trans)-> Yes / No

Call from coordinator to participant to ask whether it can commit a

transaction. Participant replies with its vote.

doCommit(trans)

Call from coordinator to participant to tell participant to commit its part of a

transaction.

doAbort(trans)

Call from coordinator to participant to tell participant to abort its part of a

transaction.

haveCommitted(trans, participant)

Call from participant to coordinator to confrm that it has committed the

transaction.

(6)

Figure 14.5

The two-phase commit protocol

Phase 1 (voting phase):

1. The coordinator sends a

canCommit

? request to each of the participants in

the transaction.

2. When a participant receives a

canCommit

? request it replies with its vote

(

Yes

or

No

) to the coordinator. Before voting

Yes

, it prepares to commit by

saving objects in permanent storage. If the vote is

No

the participant aborts

immediately.

Phase 2 (completion according to outcome of vote):

3. The coordinator collects the votes (including its own).

(a) If there are no failures and all the votes are

Yes

the coordinator

decides to commit the transaction and sends a

doCommit

request

to each of the participants.

(b) Otherwise the coordinator decides to abort the transaction and

sends

doAbort

requests to all participants that voted

Yes

.

(7)

Figure 14.6

Communication in two-phase commit protocol

canCommit?

(waiting for votes)

committed

done

prepared to commit

step

Participant

2

4

(uncertain)

prepared to commit

committed

status

step

(8)

Figure 14.7

Operations in coordinator for nested transactions

openSubTransaction(trans) -> subTrans

Opens a new subtransaction whose parent is

trans

and

returns a unique subtransaction identifer.

getStatus(trans)-> committed, aborted, provisional

Asks the coordinator to report on the status of the

(9)

Figure 14.8

Transaction

T

decides whether to commit

1

provisional commit (at N)

provisional commit (at X)

aborted (at Y)

provisional commit (at N)

provisional commit (at P)

T

(10)

Figure 14.9

Information held by coordinators of nested transactions

Coordinator of

transaction

Child

transactions

Participant

Provisional

commit list

Abort list

T

T

1

, T

2

yes

T

1

, T

12

T

11

, T

2

T

1

T

11

, T

12

yes

T

1

, T

12

T

11

T

2

T

21

, T

22

no (aborted)

T

2

T

11

no (aborted)

T

11

T

12

, T

21

T

12

but not

T

21

T

21

, T

12

(11)

Figure 14.10

canCommit

? for hierarchic two-phase commit protocol

canCommit?(trans, subTrans) -> Yes / No

Call a coordinator to ask coordinator of child

subtransaction whether it can commit a subtransaction

subTrans

. The frst argument

trans

is the transaction

(12)

Figure 14.11

canCommit

? for flat two-phase commit protoco

canCommit?(trans, abortList) -> Yes / No

Call from coordinator to participant to ask whether it can

commit a transaction. Participant replies with its

(13)

Figure 14.12

Interleavings of transactions

U

,

V

and

W

U

V

W

d.deposit(10)

lock

D

b.deposit(10)

lock

B

a.deposit(20)

lock

A

at

Y

at

X

c.deposit(30)

lock

C

b.withdraw(30)

wait at

Y

at

Z

c.withdraw(20)

wait at

Z

(14)

Figure 14.14

B

Waits for

(15)

Figure 14.14

Local and global wait-for graphs

X

T

U

Y

V

T

T

U

V

(16)

Figure 14.15

Probes transmitted to detect deadlock

(17)

Figure 14.16

Two probes initiated

(a) initial situation

(b) detection initiated at object

requested by T

(c) detection initiated at object

requested by W

(18)

Figure 14.17

Probes travel downhill

.

(b) Probe is forwarded when V starts waiting

(a) V stores probe when U starts waiting

(19)

Figure 14.18

Types of entry in a recovery file

Type of entry

Description of contents of entry

Object

A value of an object.

Transaction statusTransaction identifer, transaction status (

prepared

,

committed

aborted

) and other status values used for the two-phase

commit protocol.

(20)

Figure 14.19

Log for banking service

P

0

P

1

P

2

P

3

P

4

P

5

P

6

P

7

Object:

A

Object:B

Object:C

Object:

A

Object:B

Trans:

T

Trans:

T

Object:

C

Object:

B

Trans:

U

100

200

300

80

220

prepared committed 278

242

prepared

<A

, P

1

>

<

C, P

5

>

<B

, P

2

>

<

B

, P

6

>

P

0

P

3

P

4

Checkpoint

(21)

Figure 14.20

Shadow versions

Map at start

Map when T commits

A

P

0

A

P

1

B

P

0

'

B

P

2

C

P

0"

C

P

0"

P

0

P

0

'

P

0

"

P

1

P

2

P

3

P

4

Version store

100

200

300

80

220

278

242

(22)

Figure 14.21

Log with entries relating to two-phase commit protocol

Trans:

T

Coord’r:

T

Trans:

T

Trans:

U

Part’pant:

U

Trans:

U

Trans:

U

prepared part’pant

list: . . .

committed prepared

Coord’r: . . uncertain committed

intentions

(23)

Figure 14.22

Recovery of the two-phase commit protocol

Role

Status

Action of recovery manager

Coordinator

prepared

No decision had been reached before the server failed. It sends

abortTransaction

to all the servers in the participant list and adds the

transaction status

aborted

in its recovery fle. Same action for state

aborted

. If there is no participant list, the participants will eventually

timeout and abort the transaction.

Coordinator

committed

A decision to commit had been reached before the server failed. It

sends a

doCommit

to all the participants in its participant list (in case

it had not done so before) and resumes the two-phase protocol at step 4

(Fig 13.5).

Participant

committed

The participant sends a

haveCommitted

message to the coordinator (in

case this was not done before it failed). This will allow the coordinator

to discard information about this transaction at the next checkpoint.

Participant

uncertain

The participant failed before it knew the outcome of the transaction. It

(24)

Figure 14.23

Nested transactions

T

A

1

A

11

A

12

A

2

A

1

T

1

T

11

T

12

T

2

A

11

A

11

A

12

A

12

A

2

top of stack

T

1

T

2

T

11

Gambar

Figure 14.1Distributed transactions
Figure 14.2Nested banking transaction
Figure 14.3A distributed banking transaction
Figure 14.6Communication in two-phase commit protocol
+7

Referensi

Dokumen terkait

Pada era saat ini informasi sangat dibutuhkan oleh berbagai kalangan. Ciri utama yang menandakan dimulainya era informasi adalah internet. Jasa Warnet NadiPutra sebagai salah

penerapan metode peer assessment dan self assessment ini diharapkan siswa dapat. mengukur kemampuannya dalam memahami materi hidrokarbon, serta

IPNU-IPPNU adalah suatu organisasi kemasyarakatan dan sangat diharapkan oleh Nahdlatul Ulama, sebagai organisasi induknya, yang telah melangkah menuju kemajuan,

Sifat Fisis Dan Mekanis Laminasi Bambu Betung ( Dendrocalamus asper ( Schult.f) Backer ex Heyne ) Pada Berbagai Posisi Batang Dan Jenis Perekat.. Dibimbing oleh LUTHFI HAKIM dan

Metode penelitian yang digunakan dalam penelitian ini adalah wawancara berdasarkan faktor pembentuk identitas sosial menurut Tajfel &amp; Turner (1979) yaitu social

Nilai koefisien determinasi pada penelitian ini sebesar 0,178, sedangkan uji model (Uji F) dapat disimpulkan bahwa model regresi linier sederhana tersebut dapat digunakan

Dalam menunjang upaya mempertahankan dan melestarikan budaya dolanan tradisional, langkah yang tepat adalah dengan penerapan teknologi.. Dan teknologi game adalah

In this report, we provide evidence that nuclear protein extracts from etiolated Sorghum leaves contain two DNA binding activities (PC1 and PC2) for a promoter fragment of the C