external consistency and spanner
play

External Consistency and Spanner CS425/ECE428 SPRING 2020 NIKITA - PowerPoint PPT Presentation

External Consistency and Spanner CS425/ECE428 SPRING 2020 NIKITA BORISOV, UIUC Transactions so far Objects distributed / partitioned among different servers For load balancing (sharding) For separation of concerns /


  1. External Consistency and Spanner CS425/ECE428 — SPRING 2020 NIKITA BORISOV, UIUC

  2. Transactions so far Objects distributed / partitioned among different servers ◦ For load balancing (sharding) ◦ For separation of concerns / administration Isolation enforced using two-phase locking (2PL) ◦ Each server maintains locks on own objects ◦ Deadlocks detected using e.g., edge-chasing Atomic commit using 2PC ◦ Prepare to commit ensures durability ◦ Recover from coordinator and participant crashes

  3. Dealing with Failures Node failure ◦ Objects unavailable until recovery ◦ 2PC “stuck” after coordinator failure But! Node failure is common Drive failures => no recovery!

  4. Replication Objects distributed among 1000’s cluster nodes for load-balancing (sharding) Objects replicated among a handful of nodes for availability / durability ◦ Replication across data centers, too Two-level operation: ◦ Use transactions, coordinators, 2PC per object ◦ Use Paxos / Raft among object replicas Note: can be expensive! ◦ Coordinator sends Prepare message to leaders of each replica group ◦ Each leader uses Paxos / Raft to commit the Prepare to the group logs ◦ Once commit succeeds, reply to coordinator ◦ Coordinator uses Paxos / Raft to commit decision to its group log

  5. Example transaction read A -> acquire read lock on A read B -> acquire read lock on B write A -> promote A’s lock to write lock commit -> perform 2PC ◦ Coordinator -> A, B: prepare ◦ A, B -> OK ◦ Coordinator -> A, B: commit

  6. Read transactions Read transactions often access many data items ◦ E.g., Facebook ”news feed” ◦ E.g., Amazon front page ◦ E.g., balances across all accounts Read transactions still need (read) locks (Why?) Acquiring locks requires consensus (Why?) Locks prevent write transactions from moving forward

  7. Linearizability Serial equivalence: ◦ Total effect on system is equivalent to a run that is serial and consistent with each client’s order Linearizability ◦ Total effect on system is equivalent to a run that is serial and consistent with actual order of events E.g., buying a movie ◦ Client makes RPC to bank transfers $3.99 to Amazon account ◦ Client requests video from Amazon ◦ Amazon makes RPC to bank, does not see transfer, rejects request!

  8. Spanner: Google’s Globally-Distributed Database Wilson Hsieh representing a host of authors OSDI 2012

  9. What is Spanner? • Distributed multiversion database • General-purpose transactions (ACID) • SQL query language • Schematized tables • Semi-relational data model • Running in production • Storage for Google’s ad data • Replaced a sharded MySQL database OSDI 2012 9

  10. Example: Social Network Sao Paulo Santiago x1000 Buenos Aires San Francisco Brazil Seattle x1000 User posts User posts User posts User posts User posts Arizona Friend lists Friend lists Friend lists Friend lists Friend lists Moscow London US Berlin x1000 Paris Krakow Berlin x1000 Madrid Russia Lisbon Spain OSDI 2012 10

  11. Overview • Feature: Lock-free distributed read transactions • Property: External consistency of distributed transactions – First system at global scale • Implementation: Integration of concurrency control, replication, and 2PC – Correctness and performance • Enabling technology: TrueTime – Interval-based global time OSDI 2012 11

  12. Read Transactions • Generate a page of friends’ recent posts – Consistent view of friend list and their posts Why consistency matters 1. Remove untrustworthy person X as friend 2. Post P: “My government is repressive…” OSDI 2012 12

  13. Single Machine Block writes Generate my page Friend1 post Friend2 post … User posts User posts Friend999 post Friend lists Friend lists Friend1000 post OSDI 2012 13

  14. Multiple Machines Block writes Friend1 post User posts User posts Friend lists Friend lists Friend2 post … Generate my page Friend999 post User posts User posts Friend1000 post Friend lists Friend lists OSDI 2012 14

  15. Multiple Datacenters User posts Friend1 post x1000 Friend lists US User posts Friend2 post x1000 Friend lists Spain … Generate my page User posts Friend999 post x1000 Friend lists Brazil User posts Friend1000 post x1000 Friend lists Russia OSDI 2012 15

  16. Version Management • Transactions that write use strict 2PL – Each transaction T is assigned a timestamp s – Data written by T is timestamped with s Time <8 8 15 My friends [X] [] [P] My posts [me] X’s friends [] OSDI 2012 16

  17. Synchronizing Snapshots Global wall-clock time == External Consistency: Commit order respects global wall-time order == Timestamp order respects global wall-time order given timestamp order == commit order OSDI 2012 17

  18. Timestamps, Global Clock • Strict two-phase locking for write transactions • Assign timestamp while locks are held Acquired locks Release locks T Pick s = now() OSDI 2012 18

  19. Timestamp Invariants • Timestamp order == commit order T 1 T 2 • Timestamp order respects global wall-time order T 3 T 4 OSDI 2012 19

  20. TrueTime • “Global wall-clock time” with bounded uncertainty TT.now() time earliest latest 2*ε OSDI 2012 20

  21. Timestamps and TrueTime Acquired locks Release locks T Pick s = TT.now().latest s Wait until TT.now().earliest > s Commit wait average ε average ε OSDI 2012 21

  22. Commit Wait and Replication Start consensus Achieve consensus Notify slaves Acquired locks Release locks T Pick s Commit wait done OSDI 2012 22

  23. Commit Wait and 2-Phase Commit Start logging Done logging Acquired locks Release locks T C Committed Notify participants of s Acquired locks Release locks T P1 Release locks Acquired locks T P2 Prepared Send s Compute s for each Commit wait done Compute overall s OSDI 2012 23

  24. Example Remove X from Risky post P my friend list T C T 2 s C = 6 s =8 s =15 Remove myself from X’s friend list T P s P = 8 s =8 Time <8 8 15 [X] [] My friends My posts [P] X’s friends [me] [] OSDI 2012 24

  25. What Have We Covered? • Lock-free read transactions across datacenters • External consistency • Timestamp assignment • TrueTime – Uncertainty in time can be waited out OSDI 2012 25

  26. What Haven’t We Covered? • How to read at the present time • Atomic schema changes – Mostly non-blocking – Commit in the future • Non-blocking reads in the past – At any sufficiently up-to-date replica OSDI 2012 26

  27. TrueTime Architecture GPS GPS GPS timemaster timemaster timemaster GPS Atomic-clock GPS timemaster timemaster timemaster Client Datacenter 1 Datacenter 2 … Datacenter n Compute reference [earliest, latest] = now ± ε OSDI 2012 27

  28. TrueTime implementation now = reference now + local-clock offset ε = reference ε + worst-case local-clock drift ε +6ms 200 μs/sec reference time uncertainty 0sec 30sec 60sec 90sec OSDI 2012 28

  29. What If a Clock Goes Rogue? • Timestamp assignment would violate external consistency • Empirically unlikely based on 1 year of data – Bad CPUs 6 times more likely than bad clocks OSDI 2012 29

  30. Network-Induced Uncertainty 10 6 99.9 5 99 8 90 Epsilon (ms) 4 6 3 4 2 2 1 Mar 29 Mar 30 Mar 31 Apr 1 6AM 8AM 10AM 12PM Date Date (April 13) OSDI 2012 30

  31. Conclusions • Reify clock uncertainty in time APIs – Known unknowns are better than unknown unknowns – Rethink algorithms to make use of uncertainty • Stronger semantics are achievable – Greater scale != weaker semantics OSDI 2012 33

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend