1 / 58

Outline

Outline. Fault models in distributed systems Atomic actions Consensus problem Conclusions. Fault models in distributed systems. Multiple isolated processing nodes that operate concurrently on shared informations Information is exchanged between the processes from time to time

lisag
Download Presentation

Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline • Fault models in distributed systems • Atomic actions • Consensus problem • Conclusions Basic building blocks in Fault Tolerant distributed systems

  2. Fault models in distributed systems Multiple isolated processing nodesthat operate concurrently on sharedinformations Information isexchangedbetween the processes from time to time The goal is to design the system in such a way that the distributedapplicationis fault tolerant - A set of high level faults are identified - Systems are designedthattoleratethose faults Basic building blocks in Fault Tolerant distributed systems

  3. Fault models in distributed systems • Nodefailures • -Byzantine • -Crash • -Fail-stop • -... • Communicationfailures • -Byzantine • -Link (messageloss, orderingloss) • -Loss (messageloss) • -... Byzantine • Processes : – can crash, disobey the protocol, sendcontradictorymessages, collude with othermaliciousprocesses,... • Network: – Can corruptpackets (due to accidental faults) – Modify, delete, and introduce messages in the network Basic building blocks in Fault Tolerant distributed systems

  4. Fault models in distributed systems • The more general the fault model, the more costly and complex the solution (for the sameproblem) • Byzantine • Crash • Fail-stop • No failure COST / COMPLEXITY GENERALITY Arbitraryfailureapproach (Byzantinefailure mode) Basic building blocks in Fault Tolerant distributed systems

  5. Architecting fault tolerant systems We must consider the system model: • Asynchronous • Synchronous • Partiallysynchronous • … Developalgorithms , protocolosthat are useful building blocks for the architect of fauttolerant systems: - Atomic actions • Consensus • Trustedcomponents • ……. Basic building blocks in Fault Tolerant distributed systems

  6. Basic building blocks for fault tolerance • Atomic actions action executed in full all or has no effect • Consensus protocols correct replicas deliver the same result • etc … Basic building blocks in Fault Tolerant distributed systems

  7. Atomic Actions

  8. Atomic actions Atomic action: an action thateitherisexecuted in full or has no effectsatall • Atomic actions in distributed systems: - an action isgenerallyexecutedat more than one node - nodes must cooperate to guaranteethat - either the execution of the action completessuccessfullyateachnode or the execution of the action has no effects • The designer can associate fault tolerancemechanisms with the underlyingatomic actions of the system: - limiting the extent of errorpropagationwhen faults occur and - localizing the subsequenterror recovery Basic building blocks in Fault Tolerant distributed systems

  9. An example: Transactions in databases • Transaction: a sequence of changes to data that move the data base from a consistent state to another consistent state. • A transactionis a unit of program execution that accesses and possibly updates various data items • Transactions must be atomic: allchanges are executessuccessfully or data are notupdated Basic building blocks in Fault Tolerant distributed systems

  10. Transactions in databases Let T1 and T2 be transactions Transaction T1 Transaction T2 • A failurebefore the termination of the transaction, resultsinto a rollback (abort) of the transaction • A failure after the termination with success (commit) of the transaction must have no consequences Basic building blocks in Fault Tolerant distributed systems

  11. Banking application branch2 t1: begintransaction UPDATE account SET balance=balance + 500 WHERE account_number=45; UPDATE account SET balance=balance - 500 WHERE account_number=35; commit end transaction Account =(account_name, branch_name, balance) Eachbranchresponsableof data on local accounts t1: distributedtransaction (access data atdifferentsites) Client:t1 account_number 35 …………….. …………….. account_number 45 …………….. …………….. branch1 t1 t12:UPDATE account SET balance=balance - 500 WHERE account number=35; site2 t11: UPDATE account SET balance=balance + 500 WHERE account_number=45; site1 Basic building blocks in Fault Tolerant distributed systems

  12. Atomicityrequirement • Atomicity requirement • if the transaction fails after the update of 45 and before the update of 35, money will be “lost” leading to an inconsistent database state • the system should ensure that updates of a partially executed transaction are not reflected in the database • Atomicity of a transaction: Commitprotocol + Log in stable storage + Recovery algorithm A programmerassumesatomicity of transactions A main issue: atomicity in case of failures of various kinds, such as hardware failures and system crashes Basic building blocks in Fault Tolerant distributed systems

  13. Two-phasecommitprotocol Global decision Prepare Complete TM Local decision Decision msg Prepare msg Ack msg Ready Ready msg RM - One transaction manager TM - Manyresource managers RM - Log file (persistentmemory) - Time-out Stable storage ……………… ……………… ……………… Uncertainperiod: if the transaction manager crash, a participant with Ready in its log cannot terminate the transaction Tolerates: loss of messages crash of nodes Basic building blocks in Fault Tolerant distributed systems

  14. Three-phasecommit Precommit phase is added. Assume a permanent crash of the coordinator. A participant can substitute the coordinator to terminate the transaction. A participant assumes the role of coordinator and decides: - Global Abort, if the last record in the log Ready - Global Commit, if the last record in the log is Precommit Basic building blocks in Fault Tolerant distributed systems

  15. Recovery and Atomicity • Physical blocks: blocks residing on the disk. • Buffer blocks: blocks residing temporarily in main memory • Block movements between disk and main memory through the following operations: • - input(B) transfers the physical block B to main memory. • - output(B) transfers the buffer block B to the disk • Transactions • - Each transaction Tihas its private work-area in which local copies of all data items accessed and updated by it are kept. • perform read(X) while accessing X for the first time; • executes write(X) after last access of X. • System can perform the output operation when it deems fit. • Let BXdenote block containing X. • output(BX) need not immediately follow write(X) Basic building blocks in Fault Tolerant distributed systems

  16. Data Access main memory : buffer input(A) Physical Blocks Buffer Block A X A Buffer Block B Y B output(B) read(X) disk write(Y) x2 transactionprivatememory x1 y1 work area of T2 work area of T1 From: [Silberschatz et. al,2005] Basic building blocks in Fault Tolerant distributed systems

  17. Recovery and Atomicity • Several output operations may be required for a transaction • A transaction can be aborted after one of these modifications have been made permanent (transfer of block to disk) • A transaction can be committed and a failure of the system can occur before all the modifications of the transaction are made permanent • To ensure atomicity despite failures, we first output information describing the modifications to a Log file in stable storage without modifying the database itself Log-based recovery Basic building blocks in Fault Tolerant distributed systems

  18. DB Modification: an example Log Write Output <T0start> <T0 , A, 1000, 950> A = 950 <To , B, 2000, 2050> B = 2050 Output(BB) <T1start> <T0commit> <T1, C, 700, 600> C = 600 Output(BC) CRASH Recovery actions • undo (T1) A reset to 950 • B reset to 2050 • redo (T0) C is restored to 700 Basic building blocks in Fault Tolerant distributed systems

  19. Checkpointing • CHECKPOINT operation: output all modified buffer blocks to the disk • To Recover from system failure:- consult the Log • - redo all transactions in the checkpoint or started after the checkpoint that committed; • - undo all transaction in the checkpoint not committed or started after the checkpoint • To recover from disk failure: • - restore database from most recent dump • - apply the Log Recovery CK(T1,T3) CK(T1,T2) dump Crash <T2 start> <T3 start> <T1 start> <T2 commit> <T3,…> <T1,Y, …> <T2,X, … > <T1, Z, …> <T1, W, …> <T1 abort> Basic building blocks in Fault Tolerant distributed systems

  20. Atomic actions Advantages of atomic actions: a designer can reasonabout system design as 1) no failurehappened in the middle of a atomic action 2) separate atomic actions access to consistent data (propertycalled “serializability”, concurrency control). Basic building blocks in Fault Tolerant distributed systems

  21. Consensus protocols

  22. Consensus problem node2 Module Voter One way to achieve reliability is to have multiple replicas and take the majorityvotingamongthem node1 Module Voter In order for the majorityvoting to yield a reliablesystem, the following twoconditionsshould be satisfied: - all non faultycomponents must use the same input value - if the senderis non-faulty, thenall non-faultycomponents use the valueitprovidesas input Communication Network node3 Module Faulty Voter Whathappen with Byzantynefailures? The faulty replica can senddifferentvalues to the otherreplicas. The inputs to the voter can be different Basic building blocks in Fault Tolerant distributed systems

  23. Consensus problem The Consensus problem can be statedinformallyas: how to make a set of distributed processors achieve agreement on a valuesent by one processor despite a number of failures “ByzantineGenerals” metaphorused in the classical paper by [Lamport et al.,1982] The problemisgiven in terms of generalswhohavesurrounded the enemy. Generalswish to organize a plan of action to attack or to retreat. They must take the samedecision. Each general observes the enemy and communicateshisobservations to the others. Unfortunatelythere are traitorsamonggenerals and traitorswant to influencethis plan to the enemy’sadvantage. Theymaylieaboutwhethertheywill support a particular plan and whatothergeneralstoldthem. Basic building blocks in Fault Tolerant distributed systems

  24. ByzantineGeneralsProblem General General enemy General General General General: either a loyal general or a traitor Consensus: A: Allloyalgenerals decide upon the same plan of actions B: A small number of traitorscannot cause loyalgenerals to adopt a bad plan Basic building blocks in Fault Tolerant distributed systems

  25. ByzantineGeneralsProblem Assume - n be the number of generals - v(i) be the opinion of general i (attack/retreat) • each general icommunicate the valuev(i) by messangers to eachother general • each general finaldecisionobtained by: majority vote among the valuesv(1), ..., v(n) Absence of traitors: generalshave the samevalues v(1), ..., v(n) and they take the samedecision Basic building blocks in Fault Tolerant distributed systems

  26. ByzantineGeneralsProblem Consensus: A: Allloyalgenerals decide upon the same plan of actions B: A small number of traitorscannot cause loyalgenerals to adopt a bad plan In presence of traitors: to satisfycondition Aevery general must apply the majorityfunction to the samevalues v(1),...,v(n) to satisfycondition B for each i, if the i-th general isloyal, then the value he sends must be used by everyloyal general as the value v(i) Basic building blocks in Fault Tolerant distributed systems

  27. Interactive Consistency Simpler situation: 1 Commanding general (C) n-1 lieutenant generals (L1, ..., Ln-1) The Byzantinecommanding general C wishes to organize a plan of action to attack or to retreat; he sends the command to every lieutenant general Li Interactive Consistency IC1: Allloyal lieutenant generalsobey the samecommand IC2: The decision of loyal lieutenants must agree with the commandinggeneral’sorderif he isloyal Basic building blocks in Fault Tolerant distributed systems

  28. ByzantineGeneralsProblem Commanding General C retreat L4 attack L3 L1 L2 Commanding general lies and sends - attack to some lieutenantgenerals - retreat to some otherlieutenantgenerals How loyallieutenantgeneralsmayallreach the samedecisioneither to attack or to retreat ? Commanding general liesbutsends the samecommand to lieutenants:IC1 and IC2 are satisfied Commanding general isloyal: IC1 and IC2 are satisfied Basic building blocks in Fault Tolerant distributed systems

  29. ByzantineGeneralsProblem what L1 says he received by C Lieutenantgeneralssendmessages back and forthamongthemselves reporting the commandreceived by the Commanding General. L4 C L3 L1 decision sent by C L2 L1= (v1, v2, v3, v4) L2= (v1, v2, v3, v4) L3= (v1, v2, v3, v4) L4= (v1, v2, v3, v4) what L2 says he received by C what L3 says he received by C what L4 says he received by C Basic building blocks in Fault Tolerant distributed systems

  30. 3 Generals: one lieutenant traitor n = 3 no solutionexists L2 traitor C <attack> <attack> L1 L2 <C said retreat> In this situation (two different commands, one from the commanding general and the other from a lieutenant general), assume L1 must obey the commanding general. If L1 decides attack, IC1 and IC2 are satisfied. If L1 must obey the lieutenant general, IC2 is not satisfied RULE: if Li receives different messages, L1 takes the decision he received by the commander Basic building blocks in Fault Tolerant distributed systems

  31. 3 Generals: Commander traitor C traitor C <attack> <retreat> <C saidattack> L1 L2 <C saidretreat> The situation is the sameasbefore, and the sameruleisapplied L1 must obey the commanding general and decides attack L2 must obey the commanding general and decides retreat IC1 is violated IC2 is satisfied (the comanding general is a traitor) To cope with 1 traitor, there must be at least 4 generals Basic building blocks in Fault Tolerant distributed systems

  32. Oral Message (OM) algorithm Assumptions • the system issynchronous • anytwoprocesseshavedirectcommunicationacross a network not prone to failureitself and subject to negligible delay • the sender of a message can be identified by the receiver In particular, the following assumptionshold A1. Everymessagethatissent by a non faultyprocessiscorrectlydelivered A2. The receiver of a messageknowswhosentit A3. The absence of a message can be detected Moreover, a traitorcommandermay decide not to sendanyorder. In this case we assume a default orderequal to “retreat”. Basic building blocks in Fault Tolerant distributed systems

  33. Oral Message (OM) algorithm The Oral Message algorithm OM(m) by which a commandersends an order to n-1 lieutenants, solves the ByzantineGeneralsProblem for n = (3m +1) or more generals, in presence of atmost m traitors. ________________________________________________ majority(v1, ..., vn-1) if a majority of values vi equals v, then majority(v1, ..., vn-1) equals v else majority(v1, ..., vn-1) equalsretreat _________________________________________________ Deterministicmajority vote on the values The functionmajority(v1, ..., vn-1) returns “retrait” iftherenotexists a majoirityamongvalues Basic building blocks in Fault Tolerant distributed systems

  34. The algorithm _________________________________ Algorithm OM(0) 1. C sendsitsvalue to every Li, iÎ{1, ..., n-1} 2. Each Li uses the receivedvalue, or the valueretreatif no valueisreceived Algorithm OM(m), m>0 • C sendsitsvalue to every Li, iÎ{1, ..., n-1} • Let vi be the valuereceived by Li from C (vi = retreatif Li receives no value) Li acts as C in OM(m-1) to send vi to each of the n-2 otherlieutenants • For each i and j ¹ i, letvj be the valuethat Li received from Lj in step 2 usingAlgorithm OM(m-1) (vj = retreatif Li receives no value). Li uses the value of majority(v1, ..., vn-1)_______________________________ OM(m) is a recursive algorithmthatinvokes n-1 separate executions of OM(m-1), each of whichinvokes n-2 executions of O(m-2), etc.. For m >1, a lieutenantsendsmanyseparatedmessages to the otherlieutenants. Basic building blocks in Fault Tolerant distributed systems

  35. The algorithm OM(1) 4 generals, 1 traitor Point 1 • C sends the command to L1, L2, L3. • L1 applies OM(0) and sends the command he received from C to L2 and L3 • L2 applies OM(0) and sends the command he received from C to L1and L3 • L3 applies OM(0) and sends the command he received from C to L1 and L2 • Point 2 • L1: majority(v1, v2, v3) • L2: majority(v1, v2, v3) • //v1 command L1 says he received • //v3 command L3 says he received • L3: majority(v1, v2, v3) C <…> <…> <…> v2 v2 L1 L2 L3 v3 v1 v1 v3 Basic building blocks in Fault Tolerant distributed systems

  36. 4 Generals: Commander traitor C is a traitorbutsends the samecommand to L1, L2 ad L3 C <attack> <attack> <attack> L3 L1 L2 <attack> <attack> ................... Li: v1 = attack, v2 =attack, v3 = attack majority(....)= attack L1, L2 and L3 are loyal. They send the same command when applying OM(0) IC1 and IC2 are satisfied Basic building blocks in Fault Tolerant distributed systems

  37. 4 Generals: Commander traitor C is a traitor and sends: - attack to L1 and L2 - retrait to L3 C <retrait> <attack> <attack> L1, L2 and L3 are loyal. <retrait> L1 L2 L3 <attack> ………. <retrait> L1: v1 = attack, v2 =attack, v3 = retraitmajority(...)= attack L2: v1 = attack, v2 =attack, v3 = retrait majority(...)= attack L3: v1 = attack, v2 =attack, v3 = retrait majority(...)= attack IC1 and IC2 satisfied Basic building blocks in Fault Tolerant distributed systems

  38. 4 Generals: one Lieutenant traitor • A leutenantis a traitor • L3 is a traitor: sendsretrait to L2 and attack to L1 C <attack> <attack> <attack> <attack> L3 L1 L2 <retrait> <attack> <attack> L1: v1 = attack v2 = attack, v3 = attackmajority(...) = attack L2: v1 = attack v2 = attack, v3 = retraitmajority(...) = attack IC1 and IC2 satisfied Basic building blocks in Fault Tolerant distributed systems

  39. Oralmessage (OM) Algorithm The followingtheoremhasbeenformallyproved: Theorem: For any m, algorithm OM(m) satisfiesconditions IC1 and IC2 ifthere are more than3m generals and atmost m traitors. Let n the number of generals: n >= 3m +1 4 generals are needed to cope with 1 traitor; • generals are needed to cope with 2 traitors; 10 generals are neede to cope with 3 traitors ....... Basic building blocks in Fault Tolerant distributed systems

  40. ByzantineGeneralsProblem General General General General General OriginalByzantineGeneralsProblem Solvedassigning the role of commanding general to everylieutenant general, and running the algorithmsconcurrently General agreement among n processors, m of whichcould be faulty and behave in arbirarymanners. No assumptions on the characteristics of faulty processors Conflictingvalues are solvedtaking a deterministicmajority vote on the valuesreceivedateach processor (completelydistributed). enemy Basic building blocks in Fault Tolerant distributed systems

  41. ByzantineGeneralsProblem Solutions of the Consensus problem are expensive OM(m): each Liwaits for messagesoriginatedat C and relayed via m othersLj OM(m) requires n = 3m +1 nodes m+1 rounds message of the size O(nm+1) - message size growsateach round Algorithmevaluationusingdifferentmetrics: number of fault processors / number of rounds / message size In the literature, there are algorithmsthat are optimal for some of theseaspects. Basic building blocks in Fault Tolerant distributed systems

  42. ByzantineGeneralsProblem • The ability of the traitor to lie makes the ByzantineGeneralsproblemdifficult Restrict the ability of the traitor to lie A solution with signedmessages: allowgenerals to sendunforgeablesignedmessages (authenticatedmessages) Byzantine agreement becomesmuchsimpler A messageisauthenticatedif: 1. a messagesigned by a fault-free processor cannot be forged 2. anycorruption of the messageisdetectable 3. the signature can be authenticated by any processors Basic building blocks in Fault Tolerant distributed systems

  43. ByzantineGeneralsProblem Assmptions: (a) The signature of a loyal general cannot be forged, and anyalteration of the content of a signedmessage can be detected (b) Anyone can verify the authenticity of the signature of a general No assumptionsabout the signatures of traitorgenerals Basic building blocks in Fault Tolerant distributed systems

  44. Signedmessages Let V be a set of orders. The functionchoice(V) obtains a single order from a set of orders: _______________________________________ For choice(V) werequire: choice(Æ) = retreat choice(V) = v if V consists of the single element v choice(V) = retraitif V consists of more than 1 element _____________________________________ • x:i denotes the message x signed by general i • v:j:i denotes the value v signed by j and then the value v:j signed by i General 0 is the commander For each i, Vi contains the set of properlysignedordersthatlieutenant Li hasreceived so far Basic building blocks in Fault Tolerant distributed systems

  45. ______________________________________________________________________________________________________________________________________________ Algorithm SM(m) Vi = Æ • C signs and sendsitsvalue to every Li, iÎ{1, ..., n-1} • For each i: (A) if Li receives v:0 and Vi isempty then Vi = {v}; sends v:0:i to everyotherLj (B) if Li receives v:0:j1:...:jk and v Ï Vi then Vi = Vi È {v}; if k < m then sends v:0:j1:...:jk:i to everyotherLj , j Ï{j1, ..., jk} 3. For each i: when Li willreceive no more msgs, he obeys the orderchoice(Vi) _____________________________________________________________________ Observations: - Li ignoresmsgscontaining an ordervÎVi - Time-outs are used to determinewhen no more messageswillarrive - If Li is the m-thlieutenantthatadds the signature to the order, then the messageisnotrelayed to anyone. Basic building blocks in Fault Tolerant distributed systems

  46. Signedmessages C 3 generals, 1 traitor <attack:0> <retreat:0> C is a traitor and sends: attack to L1 and L2retrait to L3 <attack:0:1> L1 L2 <retreat:0:2> V1 = {attack, retreat} V2 = {attack, retreat} - L1 and L2 obey the order choice({attack, retreat}) • L1 and L2 know that C is a traitor because the signature of C appears in two different orders The following theorem asserting the correctness of the algorithm has been formally proved. Theorem : For any m, algorithm SM(m) solves the Byzantine Generals Problem if there are at most m traitors. Basic building blocks in Fault Tolerant distributed systems

  47. Remarks Assumption A1. Everymessagethatissent by a non faultyprocessisdeliveredcorrectly Assumption A2. The receiver of a messageknowswhosentit Assumption A3: The absence of a message can be detected Assumption A4: • a loyal general signature cannot be forged, and anyalteration of the content of a signedmessage can be detected (b) anyone can verify the authenticity of a general signature Basic building blocks in Fault Tolerant distributed systems

  48. Impossibilityresult Asynchronousdistributedsystem: no timing assumptions (no bounds on message delay, no bounds on the time necessary to execute a step) Asynchronous model of computation: attractive. - Applications programmed on thisbasis are easier to portthanthoseincorporatingspecific timing assumptions. - Synchronousassumptions are at best probabilistic: in practice, variable or unexpectedworkloads are sources of asynchrony Basic building blocks in Fault Tolerant distributed systems

  49. Impossibilityresult Consensus cannot be solveddeterministically in an asynchronousdistributed system thatissubjecteven to a single crash failure [Fisher et al. 1985] difficulty of determiningwhether a processhasactuallycrashed or isonlyvery slow Stopping a single processat an inopportune time can cause anydistributedprotocol to fail to reach consensus Circumventing the problem: Adding Time to the Model (using the notion of partialsynchrony), RandomizedByzantine consensus, Failure detectors, etc … Basic building blocks in Fault Tolerant distributed systems

More Related