Coordination 1. To do. Mutual exclusion Election algorithms Next time: Global state. q q q

Similar documents
Distributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201

Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

Coordination and Agreement

CSE 486/586 Distributed Systems

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [DISTRIBUTED MUTUAL EXCLUSION] Frequently asked questions from the previous class survey

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Mutual Exclusion. A Centralized Algorithm

Distributed Systems Coordination and Agreement

PROCESS SYNCHRONIZATION

Distributed Systems (5DV147)

Clock Synchronization. Synchronization. Clock Synchronization Algorithms. Physical Clock Synchronization. Tanenbaum Chapter 6 plus additional papers

Process Synchroniztion Mutual Exclusion & Election Algorithms

Frequently asked questions from the previous class survey

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

DISTRIBUTED MUTEX. EE324 Lecture 11

Last Class: Clock Synchronization. Today: More Canonical Problems

Synchronization. Chapter 5

Distributed Operating Systems. Distributed Synchronization

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Slides for Chapter 15: Coordination and Agreement

Homework #2 Nathan Balon CIS 578 October 31, 2004

Several of these problems are motivated by trying to use solutiions used in `centralized computing to distributed computing

Verteilte Systeme/Distributed Systems Ch. 5: Various distributed algorithms

CSE 5306 Distributed Systems. Synchronization

Time and Coordination in Distributed Systems. Operating Systems

Distributed Systems Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2016

Distributed Coordination! Distr. Systems: Fundamental Characteristics!

Synchronization. Clock Synchronization

殷亚凤. Synchronization. Distributed Systems [6]

Synchronization Part 2. REK s adaptation of Claypool s adaptation oftanenbaum s Distributed Systems Chapter 5 and Silberschatz Chapter 17

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

Distributed Mutual Exclusion

Chapter 6 Synchronization (2)

Mutual Exclusion in DS

Exam 2 Review. Fall 2011

Event Ordering Silberschatz, Galvin and Gagne. Operating System Concepts

CMPSCI 677 Operating Systems Spring Lecture 14: March 9

Introduction to Distributed Systems Seif Haridi

Distributed Systems 8L for Part IB

Failure Tolerance. Distributed Systems Santa Clara University

Distributed Systems. Lec 9: Distributed File Systems NFS, AFS. Slide acks: Dave Andersen


CSE 380 Computer Operating Systems

A Two-Layer Hybrid Algorithm for Achieving Mutual Exclusion in Distributed Systems

Slides for Chapter 12: Coordination and Agreement

Recap: Consensus. CSE 486/586 Distributed Systems Mutual Exclusion. Why Mutual Exclusion? Why Mutual Exclusion? Mutexes. Mutual Exclusion C 1

Synchronization. Distributed Systems IT332

Algorithms and protocols for distributed systems

Verteilte Systeme (Distributed Systems)

Distributed Systems Exam 1 Review Paul Krzyzanowski. Rutgers University. Fall 2016

Distributed Mutual Exclusion Algorithms

To do. Consensus and related problems. q Failure. q Raft

Last Class: Clock Synchronization. Today: More Canonical Problems

Advanced Topics in Distributed Systems. Dr. Ayman A. Abdel-Hamid. Computer Science Department Virginia Tech

How Bitcoin achieves Decentralization. How Bitcoin achieves Decentralization

Selected Questions. Exam 2 Fall 2006

Arranging lunch value of preserving the causal order. a: how about lunch? meet at 12? a: <receives b then c>: which is ok?

June 22/24/ Gerd Liefländer System Architecture Group Universität Karlsruhe (TH), System Architecture Group

Chapter 6 Synchronization

Chapter 16: Distributed Synchronization

CSE 5306 Distributed Systems

OUTLINE. Introduction Clock synchronization Logical clocks Global state Mutual exclusion Election algorithms Deadlocks in distributed systems

Chapter 18: Distributed

Coordination 2. Today. How can processes agree on an action or a value? l Group communication l Basic, reliable and l ordered multicast

Lecture 2: Leader election algorithms.

11/7/2018. Event Ordering. Module 18: Distributed Coordination. Distributed Mutual Exclusion (DME) Implementation of. DME: Centralized Approach

SEGR 550 Distributed Computing. Final Exam, Fall 2011

Failures, Elections, and Raft

Distributed Systems Leader election & Failure detection

Last time. Distributed systems Lecture 6: Elections, distributed transactions, and replication. DrRobert N. M. Watson

Paxos and Raft (Lecture 21, cs262a) Ion Stoica, UC Berkeley November 7, 2016

CSE 486/586 Distributed Systems

Agreement in Distributed Systems CS 188 Distributed Systems February 19, 2015

An Efficient Approach of Election Algorithm in Distributed Systems

Distributed Systems (ICE 601) Fault Tolerance

Distributed Systems. Fault Tolerance. Paul Krzyzanowski

Synchronization Part II. CS403/534 Distributed Systems Erkay Savas Sabanci University

Distributed Transaction Management 2003

Today: Fault Tolerance

Consensus Problem. Pradipta De

Distributed Computing. CS439: Principles of Computer Systems November 19, 2018

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1

Recap. CSE 486/586 Distributed Systems Paxos. Paxos. Brief History. Brief History. Brief History C 1

Intuitive distributed algorithms. with F#

Process groups and message ordering

A DAG-BASED ALGORITHM FOR DISTRIBUTED MUTUAL EXCLUSION ATHESIS MASTER OF SCIENCE

Distributed Computing. CS439: Principles of Computer Systems November 20, 2017

Distributed Systems. 7. Coordination and Agreement

Distributed Systems. Multicast and Agreement

Last Time. 19: Distributed Coordination. Distributed Coordination. Recall. Event Ordering. Happens-before

Event Ordering. Greg Bilodeau CS 5204 November 3, 2009

Distributed Systems 11. Consensus. Paul Krzyzanowski

Exam 2 Review. October 29, Paul Krzyzanowski 1

Silberschatz and Galvin Chapter 18

Fault Tolerance. Distributed Software Systems. Definitions

Coordination and Agreement

21. Distributed Algorithms

Distributed Systems Principles and Paradigms

Today: Fault Tolerance. Fault Tolerance

Coordination and Agreement

Transcription:

Coordination 1 To do q q q Mutual exclusion Election algorithms Next time: Global state Coordination and agreement in US Congress 1798-2015

Process coordination How can processes coordinate their action? How can they agree on a value? Two example problems Mutual exclusion As in OS for access share resources Election of a leader or a coordinator (e.g., Cristian s master goes away ) Various classical algorithms for each Mutual exclusion Central server, voting, Election Ring-based, bully 2

Assumptions on failures Channels are reliable eventual delivery But unless the system is synchronous, without time bounds (hence eventually ) Process fail only by crashing We ll look at arbitrary (Byzantine) failures later Processes are independent of each other E.g., no process forwarding messages for another How do you know a process has failed? 3

Failures and failure detectors To detect failures, a failure detector Obviously a distributed service Unreliable, not always accurate Given a process id, returns unsuspected/suspected Just a hint, may or not be true Reliable Unsuspected (still a hint) or failed Always accurate in detecting a process has failed Crash failure so by definition it s not coming back! 4

Failures and failure detectors A simple solution Use heartbeats and a maximum transmission time You can also adjust parameters at run-time For a synchronous system, this yields a reliable detector For asynchronous unreliable is the best you can get Useful if only to solve coordination problems Different processes may get different responses from failure detector Distributed means potentially different views 5

Mutual exclusion Processes want exclusive access to a shared resource A file, a printer, Application-level protocol enter() // enter critical section resourceaccess() exit() // exit critical section No shared memory or single kernel support All communication is through message passing 6

Mutual exclusion Requirements for a solution Essential requirements ME1 (safety): At most 1 process in the CS ME2 (liveness): Request to enter/exit the CS are eventually granted Sometimes, include a fairness requirement ME3 ( ordering): Requests to enter the CS are granted in happened-before order Comparing solutions Bandwidth consumed proportional to number of messages sent in entry/exit Client delay at each entry/exit operation Fault tolerance 7

Common algorithms for mutual exclusion Central server Ring- or token-based Multicast and logical clocks (Lamport s, Ricart & Agrawala s) Voting/quorum (Maekawa s) 8

Mutual exclusion Centralized Empty queue A central server grants permission To enter process sends request to server and waits for OK Server upon request if nobody is in CS, lets them go else, holds reply and queue the process Server upon release chooses oldest request and sends OK to process 2 ME1 Mutual exclusion ME2 No starvation ME3 - Ordering 2 OK 3 Request 3 No reply Request Release 3 OK 0 1 2 0 1 2 0 1 2 In CS Msgs per entry/exit 2 Delay to entry (msgs) 2 Problems Coordinator crash 9

Ring-based algorithm (token-based) Organize processes in a logical ring Exclusion is granted by having a token Token is passed around the ring Don t need it anymore? Pass it to the next ME1 Mutual exclusion ME2 No starvation 3 ME3 - Ordering 2 4 1 5 0 6 Msgs per entry/exit 1 to infinite 7 Delay to entry (msgs) 0 to N-1 Problems Lost token, process crash And out of CS In CS 10

Lamport s solution Shared priority queue Problem with centralized solution: ordering p 0 p 1 p 2 1 3 request msg 4 6 7 2 If p 2 request is granted before p 1 s that would violate fairness (ME3) request Using LC p i locally maintains Q i, part of a shared priority queue To go into critical section, p i must have replies from all others AND be at the front of Q i When it has received all replies: All other processes are aware of its request Process is aware of any earlier requests for CS 11

Lamport s solution Shared priority queue To enter critical section at p i : Stamp request with the current time T Add request to Q i Broadcast REQUEST(T) to all processes Wait for all replies and for T to reach front of Q i To leave: Pop head of Q i, broadcast RELEASE to all other On receipt of REQUEST(T ) from process p j : Add T to Q i If waiting for REPLY from p j for an earlier request T, wait until p j replies arrives Otherwise REPLY On receipt of RELEASE Pop head of Q i Msgs per entry/exit Delay to entry (msgs) 3(N-1) 3(N-1) Problems Any process crash 12

Ricart and Agrawala Improvement on Lamport s Combine request/reply Delay reply to any request arriving later than your own To get entry Multicast request Wait until getting N-1 replies Now you have it Upon getting a request If somebody has it or another process request is first, queue request, else reply immediately At exit Reply to queued requests 13

Ricart and Agrawala Three processes, p 1 and p 2 want to enter the critical section Both multicast their request with timestamp 41 and 34 41 1 41 OK 41 34 3 OK 34 ME1 Mutual exclusion ME2 No starvation OK 2 ME3 - Ordering 34 Msgs per entry/exit 2(N-1) Delay to entry (msgs) Problems 2(N-1) Process crash 14

Maekawa s voting You don t need everyone s OK, just enough of them What s enough? Any two voting sets have a non-empty intersection Each process p i maintain a voting set V i (i=1,, N), where V i {p 1,, p N } Sets V i : chosen such that i,j p i V i V i V j (at least one common member of any two voting sets) V i = k (fairness, all voting sets of the same size) Each process p j is contained in M of the voting sets V i 15

Maekawa s algorithm Makeawa showed that an optimal solution K ~ N and M = K To determine V i Order processes on a grid Nx N V i is row U column including p i 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 N= 16 For p i to enter the CS Multicast request to all processes in V i Wait until you get K replies and you have it On receipt of a request from p i at p j If in the CS or has already voted Queue request without replying Else send reply and set voted to true 16

Maekawa s voting For p i to exit the CS Set state to released and multicast this to all processes in V i On receipt of a release from p i at p j If queue is non-empty, reply to one (happened-before to avoid deadlocks) and set voted to true Else set voted to false Mutual exclusion Since for any two processes, their voting sets intersect ME1 Mutual exclusion ME2 No starvation ME3 - Ordering Ordering Used happened-before to send votes Msgs per entry/exit Delay to entry (msgs) Problems 3 N 2 N Crash of voting process 17

Back in 5 18

Election Many algorithms need a process to act as coordinator In general, it doesn t matter which one So pick the one with the largest ID/weight Elections conclude when all agree on new coordinator 19

Election algorithms Each process p i maintains the identity of the elected in the variable Elected i (or NIL) Properties to satisfy: p i, E1 Safety: Elected i = NIL or Elected = P where P is the yet noncrashed process with the largest ID E2 Liveness: All p i participate and eventually either set Elected i NIL or crash Performance measurements Bandwidth utilization proportional to number of messages sent Turnaround time Number of serialized message transmissions between begin and end of a single run 20

A ring algorithm p i, notice coordinator is down and calls an election sending an ELECTION message, with its number in it, to first successor up Recipient forward messages adding itself as candidate Who started it all, will eventually receive a message with itself in the list; elect coordinator and inform all (ELECTED message) ELECTED messages goes around the ring once 21

A ring algorithm [4,5,6,0,1,2] 3 2 [4,5,6,0,1,2,3] Leader is down, I m calling an election 4 [4] Election 2 3 4 [4,5,6,0,1] Elected - 6 1 5 1 5 [4,5,6,0] 0 [4,5,6] 6 [4,5] 0 6 7 7 22

A ring algorithm E1 is met A process has to received its own message back before sending ELECTED around so all processes before must have lower numbers E2 follows from the guaranteed traversal of the rink Msgs Problems 2(N-1) Doesn t tolerate faults 23

The Bully algorithm (Garcia-Molina) p i notice coordinator is down and calls an election p i sends ELECTION message to all processes with higher numbers Assumes every process knows who those are If no-one responds, p i is the winner Algorithm assumes a synchronous system uses timeouts to detect process failures If a process with a higher number receives the ELECTION message, reply with OK and calls an election When done, winner let everybody know with an ELECTED message 24

The Bully algorithm 4 notice coordinator is down, calls an election, sending message to all processes with higher numbers 5 and 6 (those with higher numbers) reply with OK and calls an election 2 1 5 now 5 and then 6 call an election 4 Election OK Election OK 6 No-one responds, 6 is the winner and lets everyone know 0 Coordinator 3 7 If 7 ever wakes up, it will call for elections 25

The Bully algorithm E1, assuming no process is replaced, is satisfied No two processes will think they are the coordinator since the one with lower number will defer to the leader If crashed processes are replaced by others with same identifiers E1 is not guaranteed E2 works by the assumption of reliable message delivery Msgs N - 2 to O(N 2 ) Problems System must be synchronous 26

Summary Synchronization is about doing the right thing at the right time What s the right time? An issue when you don t share clocks What s the right thing to do? Who can access what when? Who is in charge? 27