advanced database systems
play

ADVANCED DATABASE SYSTEMS Multi-Version Concurrency Control - PowerPoint PPT Presentation

Lect ure # 03 ADVANCED DATABASE SYSTEMS Multi-Version Concurrency Control (Design Decisions) @ Andy_Pavlo // 15- 721 // Spring 2019 CMU 15-721 (Spring 2019) 2 CO RRECTIO N Original SQL-92 isolation levels were not devised assuming a


  1. Lect ure # 03 ADVANCED DATABASE SYSTEMS Multi-Version Concurrency Control (Design Decisions) @ Andy_Pavlo // 15- 721 // Spring 2019

  2. CMU 15-721 (Spring 2019) 2 CO RRECTIO N Original SQL-92 isolation levels were not devised assuming a 2PL-based DBMS. A CRITIQUE OF ANSI SQL ISOLATION LEVELS SIGMOD 1995

  3. CMU 15-721 (Spring 2019) 2 CO RRECTIO N Original SQL-92 isolation levels were not devised assuming a 2PL-based DBMS. A CRITIQUE OF ANSI SQL ISOLATION LEVELS SIGMOD 1995

  4. CMU 15-721 (Spring 2019) 2 CO RRECTIO N Original SQL-92 isolation levels were not devised assuming a 2PL-based DBMS. A CRITIQUE OF ANSI SQL ISOLATION LEVELS SIGMOD 1995

  5. CMU 15-721 (Spring 2019) 3 TO DAY'S AGEN DA Overview of In-Memory MVCC

  6. CMU 15-721 (Spring 2019) 4 M ULTI- VERSIO N CO N CURREN CY CO N TRO L The DBMS maintains multiple physical versions of a single logical object in the database: → When a txn writes to an object, the DBMS creates a new version of that object. → When a txn reads an object, it reads the newest version that existed when the txn started. First proposed in 1978 MIT PhD dissertation. First implementation was InterBase (Firebird). Used in almost every new DBMS in last 10 years.

  7. CMU 15-721 (Spring 2019) 5 M ULTI- VERSIO N CO N CURREN CY CO N TRO L Main benefits: → Writers don’t block readers. → Read-only txns can read a consistent snapshot without acquiring locks. → Easily support time-travel queries. MVCC is more than just a “concurrency control protocol”. It completely affects how the DBMS manages transactions and the database.

  8. CMU 15-721 (Spring 2019) 6 SN APSH OT ISO LATIO N When a txn starts, it sees a consistent snapshot of the database that existed at the moment that the txn started. → No torn writes from active txns. → If two txns update the same object, then first writer wins. We get SI automatically for "free" with MVCC. → If we want serializable isolation, then the DBMS has to do extra stuff…

  9. CMU 15-721 (Spring 2019) 7 M VCC DESIGN DECISIO N S Concurrency Control Protocol Version Storage Garbage Collection Index Management AN EMPIRICAL EVALUATION OF IN- MEMORY MULTI- VERSION CONCURRENCY CONTROL VLDB 2017

  10. CMU 15-721 (Spring 2019) 7 M VCC DESIGN DECISIO N S Concurrency Control Protocol Version Storage Garbage Collection Index Management AN EMPIRICAL EVALUATION OF IN- MEMORY MULTI- VERSION CONCURRENCY CONTROL VLDB 2017

  11. CMU 15-721 (Spring 2019) 7 M VCC DESIGN DECISIO N S Concurrency Control Protocol Version Storage Garbage Collection Index Management AN EMPIRICAL EVALUATION OF IN- MEMORY MULTI- VERSION CONCURRENCY CONTROL VLDB 2017

  12. CMU 15-721 (Spring 2019) 7 M VCC DESIGN DECISIO N S Concurrency Control Protocol Version Storage Garbage Collection Index Management AN EMPIRICAL EVALUATION OF IN- MEMORY MULTI- VERSION CONCURRENCY CONTROL VLDB 2017

  13. CMU 15-721 (Spring 2019) 7 M VCC DESIGN DECISIO N S Concurrency Control Protocol Version Storage Garbage Collection Index Management AN EMPIRICAL EVALUATION OF IN- MEMORY MULTI- VERSION CONCURRENCY CONTROL VLDB 2017

  14. CMU 15-721 (Spring 2019) 8 CO N CURREN CY CO N TRO L PROTO CO L Approach #1: Timestamp Ordering → Assign txns timestamps that determine serial order. → Considered to be original MVCC protocol. Approach #2: Optimistic Concurrency Control → Three-phase protocol from last class. → Use private workspace for new versions. Approach #3: Two-Phase Locking → Txns acquire appropriate lock on physical version before they can read/write a logical tuple.

  15. CMU 15-721 (Spring 2019) 9 TUPLE FO RM AT TXN-ID BEGIN-TS END-TS POINTER ... DATA Unique Txn Version Next/Prev Additional Identifier Lifetime Version Meta-data

  16. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION ∞ A 1 0 1 1 ∞ B 1 0 0 1 Use read-ts field in the header to keep track of the timestamp of the last txn that read it.

  17. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Use read-ts field in the header to keep track of the timestamp of the last txn that read it.

  18. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Use read-ts field in the Txn is allowed to read header to keep track of the version if the latch is unset and its T id is between timestamp of the last txn that read it. begin-ts and end-ts .

  19. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Use read-ts field in the Txn is allowed to read header to keep track of the version if the latch is unset and its T id is between timestamp of the last txn that read it. begin-ts and end-ts .

  20. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Use read-ts field in the Txn is allowed to read header to keep track of the version if the latch is unset and its T id is between timestamp of the last txn that read it. begin-ts and end-ts .

  21. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Use read-ts field in the Txn is allowed to read Txn creates a new version header to keep track of the version if the latch is unset if no other txn holds latch and its T id is between and T id is greater than timestamp of the last txn that read it. begin-ts and end-ts . read-ts .

  22. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Use read-ts field in the Txn is allowed to read Txn creates a new version header to keep track of the version if the latch is unset if no other txn holds latch and its T id is between and T id is greater than timestamp of the last txn that read it. begin-ts and end-ts . read-ts .

  23. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 10 0 0 1 WRITE(B) Use read-ts field in the Txn is allowed to read Txn creates a new version header to keep track of the version if the latch is unset if no other txn holds latch and its T id is between and T id is greater than timestamp of the last txn that read it. begin-ts and end-ts . read-ts .

  24. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 10 0 0 1 ∞ B 2 0 10 10 WRITE(B) Use read-ts field in the Txn is allowed to read Txn creates a new version header to keep track of the version if the latch is unset if no other txn holds latch and its T id is between and T id is greater than timestamp of the last txn that read it. begin-ts and end-ts . read-ts .

  25. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 10 0 0 1 10 ∞ B 2 0 10 10 WRITE(B) Use read-ts field in the Txn is allowed to read Txn creates a new version header to keep track of the version if the latch is unset if no other txn holds latch and its T id is between and T id is greater than timestamp of the last txn that read it. begin-ts and end-ts . read-ts .

  26. CMU 15-721 (Spring 2019) 10 TIM ESTAM P O RDERIN G (M VTO ) TXN-ID READ-TS BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 10 1 1 T id =10 ∞ B 1 0 0 1 10 ∞ B 2 0 10 10 0 WRITE(B) Use read-ts field in the Txn is allowed to read Txn creates a new version header to keep track of the version if the latch is unset if no other txn holds latch and its T id is between and T id is greater than timestamp of the last txn that read it. begin-ts and end-ts . read-ts .

  27. CMU 15-721 (Spring 2019) 11 TWO - PH ASE LO CKIN G (M V2PL) TXN-ID READ-CNT BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 0 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Txns use the tuple's read- cnt field as SHARED lock. Use txn-id and read-cnt together as EXCLUSIVE lock.

  28. CMU 15-721 (Spring 2019) 11 TWO - PH ASE LO CKIN G (M V2PL) TXN-ID READ-CNT BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 0 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Txns use the tuple's read- If txn-id is zero, then the cnt field as SHARED lock. txn acquires the SHARED Use txn-id and read-cnt lock by incrementing the together as EXCLUSIVE read-cnt field. lock.

  29. CMU 15-721 (Spring 2019) 11 TWO - PH ASE LO CKIN G (M V2PL) TXN-ID READ-CNT BEGIN-TS END-TS VERSION Thread #1 ∞ READ(A) A 1 0 0 1 1 T id =10 ∞ B 1 0 0 1 WRITE(B) Txns use the tuple's read- If txn-id is zero, then the cnt field as SHARED lock. txn acquires the SHARED Use txn-id and read-cnt lock by incrementing the together as EXCLUSIVE read-cnt field. lock.

Recommend


More recommend