23 Distributed OLTP Databases - CMU 15-445/645 · PDF file 2020-02-11 · Federated...

Click here to load reader

  • date post

    31-Jul-2020
  • Category

    Documents

  • view

    0
  • download

    0

Embed Size (px)

Transcript of 23 Distributed OLTP Databases - CMU 15-445/645 · PDF file 2020-02-11 · Federated...

  • Intro to Database Systems

    15-445/15-645

    Fall 2019

    Andy Pavlo Computer Science Carnegie Mellon UniversityAP

    23 Distributed OLTP Databases

    https://db.cs.cmu.edu/ https://15445.courses.cs.cmu.edu/fall2019/ https://15445.courses.cs.cmu.edu/fall2019/ http://www.cs.cmu.edu/~pavlo/ http://www.cs.cmu.edu/~pavlo/

  • CMU 15-445/645 (Fall 2019)

    ADMINISTRIV IA

    Homework #5: Monday Dec 3rd @ 11:59pm

    Project #4: Monday Dec 10th @ 11:59pm

    Extra Credit: Wednesday Dec 10th @ 11:59pm

    Final Exam: Monday Dec 9th @ 5:30pm

    2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    L AST CL ASS

    System Architectures → Shared-Memory, Shared-Disk, Shared-Nothing

    Partitioning/Sharding → Hash, Range, Round Robin

    Transaction Coordination → Centralized vs. Decentralized

    3

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    OLTP VS. OL AP

    On-line Transaction Processing (OLTP): → Short-lived read/write txns. → Small footprint. → Repetitive operations.

    On-line Analytical Processing (OLAP): → Long-running, read-only queries. → Complex joins. → Exploratory queries.

    4

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    P3 P4

    P1 P2

    DECENTRALIZED COORDINATOR

    5

    Application Server

    Begin Request

    Partitions

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    P3 P4

    P1 P2

    DECENTRALIZED COORDINATOR

    5

    Application Server

    Query

    Partitions

    Query

    Query

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    P3 P4

    P1 P2

    DECENTRALIZED COORDINATOR

    5

    Application Server

    Safe to commit?

    Commit Request

    Partitions

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    OBSERVATION

    We have not discussed how to ensure that all nodes agree to commit a txn and then to make sure it does commit if we decide that it should. → What happens if a node fails? → What happens if our messages show up late? → What happens if we don't wait for every node to agree?

    6

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    IMPORTANT ASSUMPTION

    We can assume that all nodes in a distributed DBMS are well-behaved and under the same administrative domain. → If we tell a node to commit a txn, then it will commit the

    txn (if there is not a failure).

    If you do not trust the other nodes in a distributed DBMS, then you need to use a Byzantine Fault Tolerant protocol for txns (blockchain).

    7

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/ https://en.wikipedia.org/wiki/Byzantine_fault

  • CMU 15-445/645 (Fall 2019)

    TODAY'S AGENDA

    Atomic Commit Protocols

    Replication

    Consistency Issues (CAP)

    Federated Databases

    8

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    ATOMIC COMMIT PROTOCOL

    When a multi-node txn finishes, the DBMS needs to ask all the nodes involved whether it is safe to commit.

    Examples: → Two-Phase Commit → Three-Phase Commit (not used) → Paxos → Raft → ZAB (Apache Zookeeper) → Viewstamped Replication

    9

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (SUCCESS)

    10

    Commit Request

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (SUCCESS)

    10

    Commit Request

    Phase1: Prepare

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (SUCCESS)

    10

    Commit Request

    OK

    OK

    Phase1: Prepare

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (SUCCESS)

    10

    Commit Request

    OK

    OK

    Phase1: Prepare

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    Phase2: Commit

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (SUCCESS)

    10

    Commit Request

    OK

    OK

    OK

    Phase1: Prepare

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    Phase2: Commit

    OK

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (SUCCESS)

    10

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    Success!

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (ABORT )

    11

    Commit Request

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (ABORT )

    11

    Commit Request

    Phase1: Prepare

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (ABORT )

    11

    Commit Request

    ABORT!

    Phase1: Prepare

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (ABORT )

    11

    ABORT!

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    Aborted

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (ABORT )

    11

    ABORT!

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    Phase2: Abort

    Aborted

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    TWO-PHASE COMMIT (ABORT )

    11

    ABORT!

    OK

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    Phase2: Abort

    OK

    Aborted

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    2PC OPTIMIZATIONS

    Early Prepare Voting → If you send a query to a remote node that you know will

    be the last one you execute there, then that node will also return their vote for the prepare phase with the query result.

    Early Acknowledgement After Prepare → If all nodes vote to commit a txn, the coordinator can

    send the client an acknowledgement that their txn was successful before the commit phase finishes.

    12

    https://15445.courses.cs.cmu.edu/ https://db.cs.cmu.edu/

  • CMU 15-445/645 (Fall 2019)

    Node 1

    EARLY ACKNOWLEDGEMENT

    13

    Commit Request

    P a rticip

    a n

    t P

    a rticip

    a n

    t

    C o

    o rd

    in a to

    r

    Application Server

    Node 3

    Node 2

    https://15445.courses.cs.cmu.edu/ https://db.