Roadmap. 15-721 DB Sys. Design & Impl. Detailed Roadmap. Paper. Transactions - dfn. Reminders: Locking and Consistency



Similar documents
Concurrency Control: Locking, Optimistic, Degrees of Consistency

Transaction Management Overview

Lecture 7: Concurrency control. Rasmus Pagh

Concurrency Control. Module 6, Lectures 1 and 2

Course Content. Transactions and Concurrency Control. Objectives of Lecture 4 Transactions and Concurrency Control

Transactions and Recovery. Database Systems Lecture 15 Natasha Alechina

Transactions. SET08104 Database Systems. Napier University

Concurrency Control. Chapter 17. Comp 521 Files and Databases Fall

Concurrency control. Concurrency problems. Database Management System

Review: The ACID properties

Textbook and References

Database Tuning and Physical Design: Execution of Transactions

Introduction to Database Management Systems

Module 3 (14 hrs) Transactions : Transaction Processing Systems(TPS): Properties (or ACID properties) of Transactions Atomicity Consistency

Goals. Managing Multi-User Databases. Database Administration. DBA Tasks. (Kroenke, Chapter 9) Database Administration. Concurrency Control

Chapter 15: Recovery System

Recovery Theory. Storage Types. Failure Types. Theory of Recovery. Volatile storage main memory, which does not survive crashes.

Transaction Processing Monitors

Transactional properties of DBS

Transactions: Definition. Transactional properties of DBS. Transactions: Management in DBS. Transactions: Read/Write Model

Transactions and Concurrency Control. Goals. Database Administration. (Manga Guide to DB, Chapter 5, pg , ) Database Administration

Chapter 6 The database Language SQL as a tutorial

Applying Attribute Level Locking to Decrease the Deadlock on Distributed Database

CMSC724: Concurrency

Comp 5311 Database Management Systems. 16. Review 2 (Physical Level)

CHAPTER 6: DISTRIBUTED FILE SYSTEMS

Distributed Databases

Database Concurrency Control and Recovery. Simple database model

How To Write A Transaction System

Optimizing Concurrent Processing of Write-then-Read Transactions

CS 525 Advanced Database Organization - Spring 2013 Mon + Wed 3:15-4:30 PM, Room: Wishnick Hall 113

Figure 19.1 Interleaved processing versus parallel processing of concurrent transactions.

Homework 8. Revision : 2015/04/14 08:13

! Volatile storage: ! Nonvolatile storage:

CS 245 Final Exam Winter 2013

Generalized Isolation Level Definitions

Transactions and the Internet

Chapter 10: Distributed DBMS Reliability

TYPICAL QUESTIONS & ANSWERS

Database Internals (Overview)

How To Recover From Failure In A Relational Database System

Lesson 12: Recovery System DBMS Architectures

Serializable Isolation for Snapshot Databases

Introduction to Database Systems. Module 1, Lecture 1. Instructor: Raghu Ramakrishnan UW-Madison

Crash Recovery. Chapter 18. Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke

Lesson 9: Radicals and Conjugates

Recovery and the ACID properties CMPUT 391: Implementing Durability Recovery Manager Atomicity Durability

Chapter 16: Recovery System

Distributed Databases. Concepts. Why distributed databases? Distributed Databases Basic Concepts

Chapter 1: Introduction

Implementing New Approach for Enhancing Performance and Throughput in a Distributed Database

Information Systems. Computer Science Department ETH Zurich Spring 2012

(Pessimistic) Timestamp Ordering. Rules for read and write Operations. Pessimistic Timestamp Ordering. Write Operations and Timestamps

Physical DB design and tuning: outline

Principles of Distributed Database Systems

The ConTract Model. Helmut Wächter, Andreas Reuter. November 9, 1999

Agenda. Transaction Manager Concepts ACID. DO-UNDO-REDO Protocol DB101

DATABASE ENGINES ON MULTICORES SCALE: A PRACTICAL APPROACH. João Soares and Nuno Preguiça

Distributed Transactions

DATABASE REPLICATION A TALE OF RESEARCH ACROSS COMMUNITIES

Lecture 18: Reliable Storage

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Consistency Management for Multiple Perspective Software Development

The Classical Architecture. Storage 1 / 36

CAP Theorem and Distributed Database Consistency. Syed Akbar Mehdi Lara Schmidt

Concurrency in SQL Server Kalen Delaney Solid Quality Learning Kalen Delaney

Topics. Introduction to Database Management System. What Is a DBMS? DBMS Types

Introduction to Database Systems CS4320. Instructor: Christoph Koch CS

Udai Shankar 2 Deptt. of Computer Sc. & Engineering Madan Mohan Malaviya Engineering College, Gorakhpur, India

In This Lecture. More Concurrency. Deadlocks. Precedence/Wait-For Graphs. Example. Example

Chapter 14: Recovery System

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

File System Reliability (part 2)

Transactions and ACID in MongoDB

Databases and Information Systems 1 Part 3: Storage Structures and Indices

Distributed Data Management

Database System Architecture & System Catalog Instructor: Mourad Benchikh Text Books: Elmasri & Navathe Chap. 17 Silberschatz & Korth Chap.

Failure Recovery Himanshu Gupta CSE 532-Recovery-1

THE UNIVERSITY OF TRINIDAD & TOBAGO

Week 1 Part 1: An Introduction to Database Systems. Databases and DBMSs. Why Use a DBMS? Why Study Databases??

CPS221 Lecture - ACID Transactions

Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Distributed Database Management Systems

Datenbanksysteme II: Implementation of Database Systems Recovery Undo / Redo

Tree-Based Consistency Approach for Cloud Databases

Transactions, Views, Indexes. Controlling Concurrent Behavior Virtual and Materialized Views Speeding Accesses to Data

Distributed Database Systems

COS 318: Operating Systems

CSE 562 Database Systems

Topics. Distributed Databases. Desirable Properties. Introduction. Distributed DBMS Architectures. Types of Distributed Databases

TRANSACÇÕES. PARTE I (Extraído de SQL Server Books Online )

Introduction to Real-Time Databases

Transcription:

15-721 DB Sys. Design & Impl. Locking and Consistency Christos Faloutsos www.cs.cmu.edu/~christos Roadmap 1) Roots: System R and Ingres 2) Implementation: buffering, indexing, q-opt 3) Transactions: locking, recovery locking & degrees of consistency optimistic C.C B-trees and locking... 4) Distributed DBMSs 5) Parallel DBMSs: Gamma, Alphasort 15-721 C. Faloutsos 2 Paper Granularity of locks and degrees of consistency in a shared data base Gray, Lorie, Putzolu, Traiger IFIP Working Conf. On Modelling of DBMS pp 1-29, 1997 Detailed Roadmap Reminders transactions / ACID properties serializability; Locking; 2PL Multiple Granularity locks Degrees of consistency 15-721 C. Faloutsos 3 15-721 C. Faloutsos 4 Reminders: (see undergrad book, eg., Silberschatz, Korth + Sudarshan) transaction - DFN? ACID properties serializability - DFN locking and 2PL (deadlocks) Transactions - dfn = unit of work, eg. move $10 from savings to checking Atomicity (all or none) Consistency Isolation (as if alone) Durability recovery concurrency control 15-721 C. Faloutsos 5 15-721 C. Faloutsos 6 1

Isolation other transactions should not affect us counter-example: lost update problem: read(n) 1 1 read(n) N = N - 1 N=N-1 write(n) write(n) 15-721 C. Faloutsos 7 Interleaved execution Read(X) X=X-10 Write(X) Read(Y) Y=Y+10 Write(Y) Read(X) X = X * 1.1 Write(X) Read(Y) Y=Y*1.1 Write(Y) correct? 15-721 C. Faloutsos 8 How to define correctness? Lost update case A: Serializability: A schedule (=interleaving) is correct if it is serializable, ie., equivalent to a serial interleaving (regardless of the exact nature of the updates) examples and counter-examples: N=N-1 N= N-1 How to check for correctness? 15-721 C. Faloutsos 9 15-721 C. Faloutsos 10 N=N-1 Precedence graph N= N-1 RW, WR, WW conflicts 15-721 C. Faloutsos 11 N N Cycle -> not serializable (counter) example: Inconsistent analysis A=A-10 Write(A) B=B+10 Write(B) Sum = A Sum += B Precedence graph? 15-721 C. Faloutsos 12 2

Locking Q: how to automatically create correct interleavings? A: locks to the rescue lock(x); unlock(x) exclusive/shared locks; compatibility matrix locks are not enough: Locks are not enough (counter) examle? 15-721 C. Faloutsos 13 15-721 C. Faloutsos 14 Inconsistent analysis Inconsistent analysis w/ locks A=A-10 Write(A) B=B+10 Write(B) 15-721 C. Faloutsos 15 Sum = A Sum += B Precedence graph? L(A)... U(A) L(A)... L(B)... the problem remains! Solution?? 15-721 C. Faloutsos 16 General solution: Protocol(s) Most popular one: 2 Phase Locking (2PL) X-lock version: transactions issue no lock requests, after the first unlock THEOREM: if all transactions obey 2PL -> all schedules are serializable (*) 2PL X/S lock version Q: how to modify 2PL, for the shared/exclusive lock case? * but deadlocks are possible 15-721 C. Faloutsos 17 15-721 C. Faloutsos 18 3

2PL X/S lock version A: transactions issue no lock/upgrade request, after the first unlock/downgrade In general: growing and shrinking phase Privileges/ locks 2PL observations - limits concurrency - may lead to deadlocks (what to do, then?) - 2PLC (keep locks until commit ) Q1: lock granularity? Q2: how to trade-off correctness for concurrency? 15-721 C. Faloutsos 19 15-721 C. Faloutsos 20 Detailed Roadmap Reminders transactions / ACID properties serializability; Locking; 2PL Multiple Granularity locks Degrees of consistency Motivation - lock granularity field? record? page? table? - Pros and cons? - (Ideally, each transaction should obtain a few locks) 15-721 C. Faloutsos 21 15-721 C. Faloutsos 22 Multiple granularity what types of locks? Eg: Table1 DB Table2 X/S locks for leaf level higher levels? X/S are too restrictive! Why not go directly to the proper level? record1 record2 record-n attr1 attr2 attr1 15-721 C. Faloutsos 23 15-721 C. Faloutsos 24 4

what types of locks? X/S locks for leaf level + intent locks, for higher levels IS: intent to obtain S-lock underneath IX: intent... X-lock... S: shared lock for this level X: ex- lock for this level (SIX: shared lock here; + IX) Protocol - each xact obtains appropriate lock at highest level - proceeds to desirable lower levels - must have IS/IX lock on parent, for IS/S/IX lock on children - must have IX/SIX lock on parent, for IX/X/SIX on childre - when done, unlock items, bottom-up 15-721 C. Faloutsos 25 15-721 C. Faloutsos 26 Compatibility matrix Examples wants has IS IX S IS IX S SIX X wants to update Smith s record IX on DB IX on EMPLOYEE table X on Smith s record SIX X 15-721 C. Faloutsos 27 15-721 C. Faloutsos 28 Examples - cont d wants to give 10% raise to everybody that is below average salary IX on DB SIX on EMPLOYEE X on appropriate employee tuples OR: IX on DB X on EMPLOYEE 15-721 C. Faloutsos 29 Consistency DFN: Dirty data: updates of un-committed xacts DFN: long locks: held until commit Q: what is the impact of long/short S-locks, and long X-locks on correctness 15-721 C. Faloutsos 30 5

("long" means to hold until the transaction finishes) Degree 2: long write locks on updated items, and short read locks on items read Degree 3: long write locks on updated items, and long read locks on items read (no locks: ERRORS!) -> we may update uncommitted data -> cascaded aborts 15-721 C. Faloutsos 31 15-721 C. Faloutsos 32 -> we may read uncommitted data Degree 2: long write locks on updated items, and short read locks on items read -> we read clean data, but repeated reads may give different results 15-721 C. Faloutsos 33 15-721 C. Faloutsos 34 Degree 2: long write locks on updated items, and short read locks on items read Degree 3: long write locks on updated items, and long read locks on items read -> (= 2PLC): correct Consistency Levels Concurrency increases conversely with correctness Degree 3 is the default. 15-721 C. Faloutsos 35 15-721 C. Faloutsos 36 6

Conclusions (locks and 2PL for consistency) multiple granularity locks levels of consistency 15-721 C. Faloutsos 37 7