Coordination ofDistributed Transactions.ppt
-
Upload
seema-kalra -
Category
Documents
-
view
216 -
download
0
Transcript of Coordination ofDistributed Transactions.ppt
-
8/9/2019 Coordination ofDistributed Transactions.ppt
1/36
-
Coordination of
Distributed Transactions
Distributed Concurrency Control
19 Distributed Transaction eco!ery
-
8/9/2019 Coordination ofDistributed Transactions.ppt
2/36
-
Distributed Transaction Recovery
2 Basic Two-Phase Commit Algorithm (2PC) 2"1 2#C Durin$ %ormal &'eration 2"2 estart and Termination #rotocol
2"3 Inde'endent eco!ery 3 Transaction-Tree T(o-#)ase Commit * &'timi+ations5 ,essons ,earned
To marry is to halve your rights and to double your duties.(Arthur Schopenhauer)
-
8/9/2019 Coordination ofDistributed Transactions.ppt
3/36
-
Fundamental Problem of Distributed Commit
Problem: Transaction o'erates on multi'le ser!ers resource managers . lobal commit needs unanimous local commits of all participants (agents) Distributed system may fail 'artially
ser!er cras)es net(or failures. and creates t)e 'otential dan$er of inconsistent decisions
Approach:
Distributed )ands)a e 'rotocolno(n as two-phase commit (2PC) (it) a coordinator ta in$ res'onsibility for unanimousoutcome eco!ery considerations for in-doubt transactions
-
8/9/2019 Coordination ofDistributed Transactions.ppt
4/36
-
Idea: Getting Married over the Web
Will you ... ? Will you .. ?
Yes! Yes!
arried!
-
8/9/2019 Coordination ofDistributed Transactions.ppt
5/36
-
PC During !ormal "#eration First phase (voting): coordinator sends prepare messa$es to 'artici'ants
and (aits for yes or no !otes econd phase (decision) coordinator sends commit or rollbac messa$es to 'artici'ants and (aits for ac s Participants (rite prepared lo$ entries in !otin$ ')ase
and become in"doubt (uncertain) 'otential bloc!ing dan$er breac) of local autonomy #artici'ants (rite commit or rollbac lo$ entry in decision ')ase Coordinator (rites begin lo$ entry Coordinator (rites commit or rollbac lo$ entry
and can no( $i!e return code to t)e client s commit re uest Coordinator (rites end (done# $orgotten) lo$ entry to facilitate garbage collection
*n messa$es 2n42 forced lo$ (rites 1 unforced lo$ (rite
(it) n 'artici'ants and 1 coordinator
-
8/9/2019 Coordination ofDistributed Transactions.ppt
6/36
-
8/9/2019 Coordination ofDistributed Transactions.ppt
7/36-
$tatechart for %asic PC
committed aborted
committed1 aborted1
initial
collectin$
for$otten
initial1
're'ared1
're'are1/ yes1 're'are1/ sorry1
commit1/ ac 1
abort1/ ac 1
commit1 / ac 1 abort1 / ac 1
committed2 aborted2
initial2
're'ared2 're'are2/ yes2
're'are2/ sorry2
commit2/ ac 2
abort2/ ac 2
commit2 / ac 2 abort2 / ac 2
/ 're'are1 're'are2
yes1 : yes2/ commit1commit2
sorry1 ; sorry2
/ abort1abort2
ac 1 :ac 2 ac 1
: ac 2
coordinator partici-pant "
partici-pant 2
-
8/9/2019 Coordination ofDistributed Transactions.ppt
8/36-
Restart and Termination ProtocolFailure model: 'rocess failures= transient ser!er cras)es
net(or failures= messa$e losses messa$e du'lications assum'tion t)at t)ere are no malicious commission failures >y+antine a$reement no assum'tions about net(or failure )andlin$ can use data$rams or sessions for communication
#estart protocol a$ter $ailure (F transitions): coordinator restarts in last remembered state and resends messa$es 'artici'ant restarts in last remembered state and resends messa$e or (aits for messa$e from coordinator
Termination protocol upon timeout (T transitions): coordinator resends messa$es
and may decide to abort t)e transaction in first ')ase 'artici'ant can unilaterally abort in first ')ase and
(ait for or may contact coordinator in second ')ase
-
8/9/2019 Coordination ofDistributed Transactions.ppt
9/36-
$tatechart for %asic PC &ith Restart'Termination
committed aborted
committed1 aborted1
initial
collectin$
for$otten
initial1
're'ared1
're'are1/ yes1 're'are1/ sorry1
commit1/ ac 1
abort1/ ac 1
commit1 / ac 1 abort1 / ac 1
committed2 aborted2
initial2
're'ared2 're'are2/ yes2
're'are2/ sorry2
T1;?1
T1;?1
T2;?2
T2;?2
commit2/ ac 2
abort2/ ac 2
commit2 / ac 2 abort2 / ac 2
/ 're'are1 're'are2
yes1 : yes2/ commit1commit2
sorry1 ; sorry2
/ abort1abort2
ac 1 :ac 2 ac 1
: ac 2C-'endin$ @-'endin$
T;?
T;? T;?
/ commit1commit2
/ abort1abort2
coordinator partici-pant "
partici-pant 2
-
8/9/2019 Coordination ofDistributed Transactions.ppt
10/36-
Correctness of %asic PC
Theorem " ( a$et%):2#C $uarantees t)at if one 'rocess is in a final state t)eneit)er all 'rocesses are in t)eir committed stateor all 'rocesses are in t)eir aborted state"
Proo$ methodolog%:
Consider t)e set of 'ossible com'utation 'at)sstartin$ in $lobal state initial initial """ initial.and reason about in!ariants for states on com'utation 'at)s"
Theorem 2 (&iveness):?or a finite number of failures t)e 2#C 'rotocol(ill e!entually reac) a final $lobal state(it)in a finite number of state transitions"
-
8/9/2019 Coordination ofDistributed Transactions.ppt
11/36-
Reinfection of Partici#ants
#roblem= 2#C assumes t)at re$ular (or of 'artici'ants is finis)ed ()en t)e commit 'rotocol starts Deferred o'erations t)at are tri$$ered at commit time !iolate t)is assum'tion #re'ared 'artici'ant may become rein$ected
Solution= #artici'ant t)at recei!es re uest for deferred o'eration
after )a!in$ 're'ared itself needs to become 're'ared a$ain before re'lyin$ to t)e re uestor of t)e o'eration"
-
8/9/2019 Coordination ofDistributed Transactions.ppt
12/36-
Inde#endent Recovery
Theorem ':Ander t)e single-$ailure assumption it is 'ossible to desi$n
a distributed commit 'rotocol so t)at it can$uarantee independent recover% for a failed 'rocess"
Proo$ s!etch:
@!oid $lobal states ()ic) )a!e bot) local commit and abortstates in t)eir set of 'ossible $lobal successor states"Coordinator adds (illin$-to-commit state in bet(een collectin$and commit states and ma es T transition from collectin$ to abort"#artici'ant ma es ? transition from 're'ared to abort"
ndependent recovery* ability of a failed and restarted 'rocessto terminate )is 'art of t)e 'rotocol (it)out communicatin$to ot)er 'rocesses"
-
8/9/2019 Coordination ofDistributed Transactions.ppt
13/36
-
8/9/2019 Coordination ofDistributed Transactions.ppt
14/36-
Distributed Transaction Recovery
2 >asic T(o-#)ase Commit @l$orit)m ' Transaction-Tree Two-Phase Commit * &'timi+ations
5 ,essons ,earned
-
8/9/2019 Coordination ofDistributed Transactions.ppt
15/36-
Transaction(Tree )ierarchical PC
Durin$ transaction eBecution t)e transaction formsa process tree rooted at transaction initiator (it)
bilateral communication lin s accordin$ to re uest-re'ly interactions
@t commit time t)e 'rocess tree can be $lattened 'ro!ided t)at all 'artici'ants are no(n to t)e coordinator
and t)at establis)in$ ne( communication lin s is ineB'ensi!e re-used as it (as usin$ a hierarchical form of 2#C (it) intermediate nodes bein$ bot) 'artici'ants and sub-coordinators restructured to c)oose a coordinator different from t)e initiator
considerin$ reliability and s'eed of 'rocesses and t)e communication to'olo$y and 'rotocol coordinator trans$er
-
8/9/2019 Coordination ofDistributed Transactions.ppt
16/36-
Flattened vs* )ierarchical Commit Tree
?lattened 2#C=
communication durin$transaction eBecution
communication durin$commit 'rotocol
initiator 'rocess 0.
'rocess 3 'rocess 1
'rocess 2 'rocess * 'rocess 5
initiator 'rocess 0.
'rocess 3 'rocess 1
'rocess 2 'rocess * 'rocess 5
ierarc)ical 2#C=
-
8/9/2019 Coordination ofDistributed Transactions.ppt
17/36-
Illustration of )ierarchical PC nitiator &rocess '
're'are
yes
&rocess &rocess + &rocess , &rocess -
're'are 're'are
're'are 're'are
yes yesyesyes
commit
ac
commit
commitcommit commit
ac ac ac ac
-
8/9/2019 Coordination ofDistributed Transactions.ppt
18/36-
Distributed Transaction Recovery
2 >asic T(o-#)ase Commit @l$orit)m 3 Transaction-Tree T(o-#)ase Commit ptimi*ations
*"1 #resumed-@bort and #resumed-Commit *"2 ead-only Subtrees *"3 Coordinator Transfer *"* educed >loc in$
5 ,essons ,earned
-
8/9/2019 Coordination ofDistributed Transactions.ppt
19/36-
PC %ottlenec+s and "#timi,ations
oals= reduce t)e number of messa$es and forced lo$ (rites for )i$)er t)rou$)'ut s)orten t)e critical 'at) until local loc s can be released for faster res'onse time reduce t)e 'robability of bloc in$
#ossible o'timi+ations= fe(er messa$es and forced lo$ (rites by 'resum'tion in t)e case of missin$ information eliminatin$ read-only subtrees as early as 'ossible dynamic. coordinator transfer 'rotocols (it) reduced bloc in$ at eB'ense of more messa$es.
-
8/9/2019 Coordination ofDistributed Transactions.ppt
20/36-
PC &ith Presum#tion
Idea= 'artici'ants donEt need to force commit/abort lo$ entry can in uire coordinator if in doubt if coordinator )as already for$otten t)e transaction
it re'lies to t)e in uiry (it) a presumed result coordinator may e!en be able to for$et transaction(it)out ac s from 'artici'ants
#roblem= need to ensure t)at t)e coordinatorEs 'resumed result is consistent amon$ t(o cases of missin$ information= a. transaction )as not yet entered t)e decision ')ase early loser. b. transaction )as been decided and $arba$e collected for$otten trans".
or needs to be able to discriminate t)e t(o cases
bservation* $orcing the begin log entry is usually unnecessary/losing it is never a correctness problem
-
8/9/2019 Coordination ofDistributed Transactions.ppt
21/36-
Illustration of Presumed(-bort Protocol &rocess '
're'are
%oordinator &rocess &rocess +
force-(rite 're'ared
're'are
're'areforce-(rite
're'aredyes
yes
force-(rite 're'ared
no
abort abort
(riterollbac
(riterollbac
abort
(riterollbac
Case 1= transaction abort
&rocess '
're'are
%oordinator &rocess &rocess +
force-(rite 're'ared
're'are
're'areforce-(rite
're'aredyes
yes
force-(rite 're'ared
yes
commit commit
$orce -(ritecommit
$orce -(ritecommit
commit
$orce -(ritecommit
Case 2= transaction commit
$orce-wri tecommit
ac! ac! ac!
writeend
-
8/9/2019 Coordination ofDistributed Transactions.ppt
22/36-
Illustration of Presumed(Commit Protocol
Case 1= transaction abort Case 2= transaction commit
&rocess '
're'are
%oordinator &rocess &rocess +
force-(rite 're'ared
're'are
're'areforce-(rite
're'aredyes
yes
force-(rite 're'ared
no
abort abort
force-(riterollbac force-(riterollbac abort
force-(riterollbac
force-(rite be$in
forc e-(rite be$in
force-(riterollbac
ac ac ac
(rite
end
(rite
end
&rocess '
're'are
%oordinator &rocess &rocess +
force-(rite 're'ared
're'are
're'areforce-(rite
're'aredyes
yes
force-(rite 're'ared
yes
commit commit
force-.(ritecommit(ritecommit commit
(ritecommit
force-(rite be$in
forc e-(rite be$in
force-(ritecommit
-
8/9/2019 Coordination ofDistributed Transactions.ppt
23/36-
Further "#timi,ations and ./tensions
#resumed-commit (it) non-forced be$in lo$ entry=
identify list of transaction ids of 'otential loser transactions inter!al of ids minus transactions (it) commit lo$ entry. by means of non-forced 'eriodic lo$ entries can no( discriminate for$otten (inners from early losers but may be unable to $arba$e-collect some lo$ entries after failures
Co-eBistence of #@ and #C 'artici'ants in )etero$eneous federation'resumed-any 'rotocol.= coordinator force-(rites lo$ entries so t)at it can co'e (it)
bot) #@ and #C 'artici'ants coordinator needs to no( ty'e of 'artici'ant to be included in be$in lo$ entry. and sends and eB'ects messa$es accordin$ to
'artici'ant ty'e
-
8/9/2019 Coordination ofDistributed Transactions.ppt
24/36
-
8/9/2019 Coordination ofDistributed Transactions.ppt
25/36-
Read(only $ubtree "#timi,ation
ead-only leaf-node 'artici'ant !otes 6read-only7
and releases all its loc s ead-only intermediate node !otes 6read-only7 ()en it )as recei!ed all !otes and none of t)em is 6yes7 or 6no7 Coordinator eliminates read-only subtrees from decision ')ase
ead-only o'timi+ation more effecti!e for #@ t)an for #C because #C still needs a forced be$in lo$ entry"#@ can terminate read-only transaction (it) +ero lo$$in$ cost"
%aveat (it) re$ard to reinfected 'artici'ants=If t)ere is a non-+ero 'robability of some 'artici'ant )a!in$to 'erform deferred o'erations none of t)e read-only 'artici'antmust release its loc s"&t)er(ise t)e resultin$ )istory could be $lobally non-seriali+able"
-
8/9/2019 Coordination ofDistributed Transactions.ppt
26/36
-
8/9/2019 Coordination ofDistributed Transactions.ppt
27/36-
Initiator( vs* Coordinator(Rooted Process Tree
@
> C
F ?D
Durin$ transaction eBecution= Durin$ commit 'rotocol=
C
F ?@
>
D
initiator coordinator
-
8/9/2019 Coordination ofDistributed Transactions.ppt
28/36-
Illustration of 0ast(-gent "#timi,ation
&rocess '( nitiator)
&rocess &rocess +(%oordinator)
force-(rite 're'ared
6yes / 're'are / coordinator transfer7
force-(rite 're'ared
6yes / 're'are / coordinator transfer7
force-(rite commit6commit7
force-(rite commit6commit7
force-(rite commit6ac 7
6ac 7
(rite end
-
8/9/2019 Coordination ofDistributed Transactions.ppt
29/36
ll f
-
8/9/2019 Coordination ofDistributed Transactions.ppt
30/36-
Illustration of Dynamic PC
@
> C
F ?D
1= @ 're'are > @ 're'are C2= > 're'are D > 're'are F3= C 're'are ? C 're'are *= D yes > F yes >
> 're'ared5= > yes @
@ 're'ared= @ yes C8= ? yes C yes C
C becomes coordinator
1 1
2 2 3 3
* *
5
8 8
P l &i h R d d %l i
-
8/9/2019 Coordination ofDistributed Transactions.ppt
31/36-
Protocols &ith Reduced %loc+ing T)ree-')ase commit 'rotocol 3#C.= a!oid $lobal state (it) bot) local abort and local commit
in t)e set of 'ossible $lobal successor states usin$ t)ree ')ases= !otin$ dissemination decision no bloc in$ under sin$le-failure assum'tion and still correct in arbitrary failure situations
Coo'erati!e termination= in-doubt 'artici'ants contact ot)er 'artici'ants rat)er t)an (aitin$ for coordinator needs 'artici'ant list included in 're'are messa$e.
euristic commit or abort= in-doubt 'artici'ants on critical ser!ers
ma e unilateral decision u'on eBtra-lon$ timeout based on ty'e of transaction e"$" abort for (it)dra(al.
-
8/9/2019 Coordination ofDistributed Transactions.ppt
32/36-
Distributed Transaction Recovery
2 >asic T(o-#)ase Commit @l$orit)m 3 Transaction-Tree T(o-#)ase Commit * &'timi+ations
+ &essons &earned
-
8/9/2019 Coordination ofDistributed Transactions.ppt
33/36-
0essons 0earned 2#C is a fundamental !ersatile and standardi+ed buildin$ bloc
for transactional federations includin$ Internet a''lications
Susce'tibility to bloc in$ is in)erent and t)e 'rice for consistency Scalability is limited to fe( 'artici'ants async)ronously ueued transactions are an alternati!e 'ro!ide atomicity and t)us need 2#C but sacrifice isolation
&'timi+ations aim to reduce forced lo$$in$ and messa$es #@ and #C. s)orten time until loc release read-only !otes last-a$ent o'timi+ation dynamic 2#C.
reduce bloc in$ coo'erati!e termination 3#C. Coordinator transfer is crucial to a!oid de'endency on
'oorly administered initiator or unreliable ser!era''lication ser!er is often an a''ro'riate coordinator.
-
8/9/2019 Coordination ofDistributed Transactions.ppt
34/36-
- 0oo+ %ac+
&art * %oncurrency %ontrol 3 %otions of Correctness #G* CC @l$orit)ms5 Gulti!ersion CC %otions of Correctness &G
8 CC @l$orit)ms on &bHects< CC on elational D>9 CC on Searc) Structures10 Im'l" : #ra$matic Issues
&art * 0ecovery11 Transaction eco!ery12 Cras) eco!ery Correctness13 C @l$orit)ms #G1* C @l$orit)ms &G
15 S'ecial Issues of eco!ery1 Gedia eco!ery18 @''lication eco!ery
&art 1* %oordination o$ 2istributed Transactions1< Distributed CC19 Distributed Transaction eco!ery
-
8/9/2019 Coordination ofDistributed Transactions.ppt
35/36
-
Ta+e(-&ay Messages
Transactions are an im'ortant (ay of 'ro!idin$ eBecution $uarantees
T)eir basic abstraction mec)anisms allo(for a )ost of a''lications to be ca'tured
T)eir fundamental al$orit)mic a''roac)es
center around a fe( conce'ts Transactional $uarantees )a!e eB'anded(ay beyond t)e database area
-
8/9/2019 Coordination ofDistributed Transactions.ppt
36/36
"utloo+
Transactions at least atomicity. on mobile 'latforms e"$" follo(in$ an auction from a car in motion s)o''in$ o!er t)e cell ')one ()ile in a train
Transactions in!ol!in$ 'rocess eBecutions and(eb ser!ices e"$"
JS-Coordination includin$ a$reement coordination asin 2#C and business acti!ity coordination JS-Transaction and Ka!a Transaction @#I KT@. &@SIS >usiness Transactions #rotocol