====== Transactions ====== ===== ACID ===== * Atomicity: All ops happen, or none * Consistency: Data will be consistent, no constraints violated * Isolation: One transaction cannot read from another non-completed one. If t2 reads write from t1, needs to wait. * Durability: Changes have been recorded ===== CAP ===== "In presence of a network partition, one has to choose between **consistency** and **availability**". ==== Consistency ==== * Strong consistency * Timeline consistency: Typically async master-slave replication. * Eventual consistency: Temporarily inconsistent ====== Scenario ====== Scaling out NOSQL across regions/public clouds. Partitioned db across clusters. How to ensure that transaction is commited on all nodes. Ensuring atomicity: Multi-phase commit, pessimistic read-write locking But: Network partitions