Lecture 9: Bayou, Optimistic Concurrency Control (OCC) Both Tra and Bayou follow OCC, and put conflict resolution back to the user. Tra does this in a traditional filesystem, and bayou opens up the data model a bit more. Tra can tell you whether a conflict has happened, but Bayou lets programmer specify how to detect semantic conflicts, and how to resolve them on a per-application level. =Bayou= Assume each computer contains a shared file, and each keeps a list of local modifications to the file. Each writes in some local order, but the logs eventually get executed in some total order that makes system consistent (eventually). Log entries are not data, they are procedures. Interesting problem is what happens when an entry on each machine for the same logical part of the file has two different write procedures. Such a conflict is detected by running a user-level query that determines if next write will conflict with someone else's state. If a conflict happens, some user-level "merging" code runs. Updates are actually marked tentative until system decides that enough servers have merged data that the system has seen previous writes. It would be awkward to sync with every server in the system before turning tentative writes into committed/stable writes. Instead of causing everyone to speak with everyone else, one of the replicas is called the master replica. It decides the total order and tries to merge in earlier non-conflicting data, helping decide when the state is stable. Information eventually spreads through an anti-entropy gossip protocol, in which peers talk to each other if they have new information. Timestamps are logical (Lamport) clocks. Everyone keeps a local counter. If A and B talk, and A has counter 3, and B has counter 11, then A and B update to 12. Not sure how master decides between two logical counters