Synchronization in Distributed Systems
Tom Kelliher, CS43
Apr. 9, 1996
Questions on the homework?
Why bother?
- Timestamps on files.
- Basis for mutual exclusion algorithms.
The differences between non-distributed systems:
- Multiple crystals, individual drifts.
- Processes on different systems: different senses of time.
What is ``clock skew?''
Why not have a central time server?
- Single point of failure.
- Network congestion.
- Network latency. (Fixed with ``logical clocks.'')
Lamport.
Internally consistent set of clocks, no relationship to real time.
- Total order vs. partial order.
- Time doesn't matter --- order of events does.
- Non-interacting processes don't need to synch.
Happens-before ( -->)
- if a and b are events in the same process and a
occurs before b, then a --> b is true.
- if a is the event of a message being sent by one process and
b is the event of the message being received by another process, then
a --> b is true.
Externally consistent clock.
- International Atomic Time (TAI).
- Universal Coordinated Time (UTC) and leap seconds.
- See xntpd(8) and referenced RFCs.
A centralized algorithm:
- Query time server.
- Set clock, adjusting for message delay.
How often to send queries?
A decentralized algorithm:
- Once an epoch, broadcast your current time
- Collect times from other broadcasts.
- Discard outliers, set time to average.
Suppose the network gets partitioned, etc.?
Read, write caching in a distributed file system.
Leases.
Mutual exclusion coordinator process.
Network saturation, fault tolerance.
Number of messages required in entering critical region.
- Send out a broadcast/multicast message containing:
- Critical region name.
- Process number.
- Current time.
Every message should be acknowledged. (At this layer!!)
- On message receipt:
- If no intention of entering critical region, send back ``OK.''
- If in critical region, don't reply; queue request and send ``OK''
on exit.
- Otherwise, use timestamp to determine priority and act
accordingly.
- Numerous processes attempting to enter a critical region?
- Importance of time synchronization?
Fault tolerance.
Number of messages required in entering critical region.
Coordinator should be ``highest numbered'' process.
No knowledge of who's crashed, who's working.
When a process notices a coordinator is down:
- Send election message to higher numbered processes.
- If no response, you're the coordinator.
- If a ``higher up'' responds, you're finished.
On receipt of an election message:
- If sender is lower numbered, send OK and start an election.
Whoever wins sends a coordinator message to all lower numbered processes.
Number of messages?
Processes connected in a logical ring.
When a process notices a coordinator is down:
- Send election message an ``up'' list to next live process.
- Each process adds its number to list and passes list.
- Originator, upon receipt, converts list to coordinator message.
Number of messages?
How are processes added, removed from ring?
Higher-level abstraction.
May consist of several events, either:
Can't allow for some occurring.
Examples:
- Transferring money.
- Booking airline tickets.
Mirrored disks.
Algorithm:
- Update master disk.
- Update slave disk.
Block mismatch after a crash?
Bad Block?
Fault tolerance?
- BeginTransaction.
- EndTransaction.
- AbortTransaction.
- Read --- Example of a transaction event.
- Write --- Ditto.
Properties:
- Atomic.
- Consistent --- No invariants violated.
- Isolated --- Synchronization.
- Durable --- Permanent.
Nested transactions --- May have to back out of child if parent aborts.
How?
How are files handled?
Log event, before performing it.
Rollback for aborts.
Use log to recover from crashes.
Extremely useful for distributed transactions.
- Coordinator writes, sends prepare message.
- Subordinates write, send ready message.
- Coordinator collects replies, decides what to do.
- Coordinator writes, sends commit/abort message.
- Subordinates write, perform commit/abort, send finished message.
- Growing phase --- Acquire.
- Shrinking phase --- Release.
Strict two-phase locking: shrinking only occurs after commit/abort.
Prevents cascaded transaction aborts.
Not much work done here. Opportunities to become famous!!
Thomas P. Kelliher
Wed Apr 3 14:01:40 EST 1996
Tom Kelliher