The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
Why did they pursue eventual consistency
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
Okay, well, the idea is that you have an East Coast database and a West Coast database and they're replicas.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
So you want them to be the same.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
If you say, I'm going to do a transaction, I'm going to decrement by one the number of widgets in the West Coast warehouse.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
Then I'm going to, before I commit that transaction, I'm going to update the East Coast warehouse, pay a message over and back to update it.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And then to make sure everything goes well, it takes another round trip of message to make sure that both of them actually do the commit correctly.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
So it's expensive to do a distributed commit.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And it still is.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And so the idea was, well, you do the West Coast update, you decrease the widgets by one, you just send a message asynchronously and not in a transaction so that eventually the East Coast warehouse gets decremented by one.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
So meanwhile, if you're on the East Coast, you decrement foodstuffs by one, you send an asynchronous message, eventually the West Coast gets it, and eventually everything settles out.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
So if you're allowed to go below zero,
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
then what will happen is if the East Coast guy and the West Coast guy simultaneously sell the last widget, then eventually the state of the warehouse will be minus one and somebody won't get their widget.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And so if you're allowed, like Amazon to say, usually ships in 24 hours, then maybe you're allowed to oversell.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
But most enterprises can't do that.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And so eventual consistency just doesn't work.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
So we talked a million hours ago about referential integrity.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
So referential integrity in a sales system is integrity constraint is stock is greater than minus one.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And that fails.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
with eventual consistency.
The Peterman Pod
Turing Award Winner: Postgres, Disagreeing with Google, Future Problems | Mike Stonebraker
And so Jeff Dean of Google finally figured that out.