Heartbeat works with two nodes, but what if there are more nodes?
Check each node to see if they’re alive
- Problem: When every nodes does this, there is a n^2 communications
One node keeps track of every other node’s status
Each node checks the node adjacent to it
program1
a.withdraw(100)
b.deposit(100)
program2
total = a.getBalance()
total += b.getBalance()
total += c.getBalance()
If these programs are running concurrently, there are many ways the total
can be calculated wrong
- Atomicity
- Correct (usually called Consistency in databases)
- Isolation
- Durability
https://cse.buffalo.edu/~stevko/courses/cse486/spring13/lectures/21-concurrency1.pdf
- when we’re drawing lines between conflicting operations like above, we don’t want the lines to cross
begin Transaction
a.withdraw(
commit
- Send pings to all servers and wait for ACKs
- If we receive all ACKs then commit the transactions
-> CanCommit?
<- Vote (y/n?)
-> Commit or Abort
- 2pc is safe because either everyone commits or everyone aborts in most cases
- 2pc is not live because you can end up waiting forever for a response
- not safe
- live