Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Similar documents
Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

TRANSACTION MANAGEMENT [CH 16]

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Review: The ACID properties

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 20 Introduction to Transaction Processing Concepts and Theory

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Introduction to Transaction Processing Concepts and Theory

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 17-1

Chapter 4 Threads. Operating Systems: Internals and Design Principles. Ninth Edition By William Stallings

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago

Transaction Processing Concepts and Theory. Truong Tuan Anh CSE-HCMUT

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Data diverse software fault tolerance techniques

Python Programming: An Introduction to Computer Science

Reliable Transmission. Spring 2018 CS 438 Staff - University of Illinois 1

Operating System Concepts. Operating System Concepts

ECE 650 Systems Programming & Engineering. Spring 2018

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Programming with Shared Memory PART II. HPC Spring 2017 Prof. Robert van Engelen

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software

CMSC Computer Architecture Lecture 15: Multi-Core. Prof. Yanjing Li University of Chicago

CMSC22200 Computer Architecture Lecture 9: Out-of-Order, SIMD, VLIW. Prof. Yanjing Li University of Chicago

Federated Transaction Management with Snapshot Isolation

Master Informatics Eng. 2017/18. A.J.Proença. Memory Hierarchy. (most slides are borrowed) AJProença, Advanced Architectures, MiEI, UMinho, 2017/18 1

Threads and Concurrency in Java: Part 1

Outline. CSCI 4730 Operating Systems. Questions. What is an Operating System? Computer System Layers. Computer System Layers

CMSC Computer Architecture Lecture 10: Caches. Prof. Yanjing Li University of Chicago

Threads and Concurrency in Java: Part 1

. Written in factored form it is easy to see that the roots are 2, 2, i,

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

Avid Interplay Bundle

Behavioral Modeling in Verilog

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

% Sun Logo for. X3T10/95-229, Revision 0. April 18, 1998

SCI Reflective Memory

Big-O Analysis. Asymptotics

BOOLEAN MATHEMATICS: GENERAL THEORY

IMP: Superposer Integrated Morphometrics Package Superposition Tool

CMSC Computer Architecture Lecture 11: More Caches. Prof. Yanjing Li University of Chicago

Using VTR Emulation on Avid Systems

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

n Learn how resiliency strategies reduce risk n Discover automation strategies to reduce risk

n Maurice Wilkes, 1949 n Organize software to minimize errors. n Eliminate most of the errors we made anyway.

CMPT 125 Assignment 2 Solutions

Python Programming: An Introduction to Computer Science

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Lazy Type Changes in Object-oriented Database. Shan Ming Woo and Barbara Liskov MIT Lab. for Computer Science December 1999

Database Technology. Topic 8: Introduction to Transaction Processing

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

Homework 1 Solutions MA 522 Fall 2017

Course Site: Copyright 2012, Elsevier Inc. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Foundation of Database Transaction Processing. Copyright 2012 Pearson Education, Inc.

Ones Assignment Method for Solving Traveling Salesman Problem

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup

Fast Fourier Transform (FFT) Algorithms

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

Arithmetic Sequences

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

transaction - (another def) - the execution of a program that accesses or changes the contents of the database

Τεχνολογία Λογισμικού

Elementary Educational Computer

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

RECOVERY CHAPTER 21,23 (6/E) CHAPTER 17,19 (5/E)

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Big-O Analysis. Asymptotics

Customer Portal Quick Reference User Guide

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Multi-Threading. Hyper-, Multi-, and Simultaneous Thread Execution

MOTIF XF Extension Owner s Manual

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria.

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor Advanced Issues

CS 11 C track: lecture 1

Outline n Introduction n Background o Distributed DBMS Architecture

% Sun Logo for Frame. X3T10/95-229, Revision 2. September 28, 1995

MR-2010I %MktBSize Macro 989. %MktBSize Macro

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Part A Datapath Design

ICS Regent. Communications Modules. Module Operation. RS-232, RS-422 and RS-485 (T3150A) PD-6002

Lecture 6. Lecturer: Ronitt Rubinfeld Scribes: Chen Ziv, Eliav Buchnik, Ophir Arie, Jonathan Gradstein

Chapter 10 : Concurrency Control

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers?

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions

FAST BIT-REVERSALS ON UNIPROCESSORS AND SHARED-MEMORY MULTIPROCESSORS

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

A Reservation-Based Extended Transaction Protocol

The Magma Database file formats

Goals of the Lecture Object Constraint Language

Parabolic Path to a Best Best-Fit Line:

Graphs. Minimum Spanning Trees. Slides by Rose Hoberman (CMU)

Appendix D. Controller Implementation

Computers and Scientific Thinking

COMP Parallel Computing. PRAM (1): The PRAM model and complexity measures

Transcription:

Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe

CHAPTER 20 Itroductio to Trasactio Processig Cocepts ad Theory Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe

Itroductio Trasactio Describes local uit of database processig Trasactio processig systems Systems with large databases ad hudreds of cocurret users Require high availability ad fast respose time Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-3

20.1 Itroductio to Trasactio Processig Sigle-user DBMS At most oe user at a time ca use the system Example: home computer Multiuser DBMS May users ca access the system (database) cocurretly Example: airlie reservatios system Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-4

Itroductio to Trasactio Processig (cot d.) Multiprogrammig Allows operatig system to execute multiple processes cocurretly Executes commads from oe process, the suspeds that process ad executes commads from aother process, etc. Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-5

Itroductio to Trasactio Processig (cot d.) Iterleaved processig Parallel processig Processes C ad D i figure below Figure 20.1 Iterleaved processig versus parallel processig of cocurret trasactios Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-6

Trasactios Trasactio: a executig program Forms logical uit of database processig Begi ad ed trasactio statemets Specify trasactio boudaries Read-oly trasactio Read-write trasactio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-7

Database Items Database represeted as collectio of amed data items Size of a data item called its graularity Data item Record Disk block Attribute value of a record Trasactio processig cocepts idepedet of item graularity Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-8

Read ad Write Operatios read_item(x) Reads a database item amed X ito a program variable amed X Process icludes fidig the address of the disk block, ad copyig to ad from a memory buffer write_item(x) Writes the value of program variable X ito the database item amed X Process icludes fidig the address of the disk block, copyig to ad from a memory buffer, ad storig the updated disk block back to disk Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-9

Read ad Write Operatios (cot d.) Read set of a trasactio Set of all items read Write set of a trasactio Set of all items writte Figure 20.2 Two sample trasactios (a) Trasactio T1 (b) Trasactio T2 Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-10

DBMS Buffers DBMS will maitai several mai memory data buffers i the database cache Whe buffers are occupied, a buffer replacemet policy is used to choose which buffer will be replaced Example policy: least recetly used Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-11

Cocurrecy Cotrol Trasactios submitted by various users may execute cocurretly Access ad update the same database items Some form of cocurrecy cotrol is eeded The lost update problem Occurs whe two trasactios that access the same database items have operatios iterleaved Results i icorrect value of some database items Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-12

The Lost Update Problem Figure 20.3 Some problems that occur whe cocurret executio is ucotrolled (a) The lost update problem Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-13

The Temporary Update Problem Figure 20.3 (cot d.) Some problems that occur whe cocurret executio is ucotrolled (b) The temporary update problem Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-14

The Icorrect Summary Problem Figure 20.3 (cot d.) Some problems that occur whe cocurret executio is ucotrolled (c) The icorrect summary problem Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-15

The Urepeatable Read Problem Trasactio T reads the same item twice Value is chaged by aother trasactio T betwee the two reads T receives differet values for the two reads of the same item Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-16

Why Recovery is Needed Committed trasactio Effect recorded permaetly i the database Aborted trasactio Does ot affect the database Types of trasactio failures Computer failure (system crash) Trasactio or system error Local errors or exceptio coditios detected by the trasactio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-17

Why Recovery is Needed (cot d.) Types of trasactio failures (cot d.) Cocurrecy cotrol eforcemet Disk failure Physical problems or catastrophes System must keep sufficiet iformatio to recover quickly from the failure Disk failure or other catastrophes have log recovery times Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-18

20.2 Trasactio ad System Cocepts System must keep track of whe each trasactio starts, termiates, commits, ad/or aborts BEGIN_TRANSACTION READ or WRITE END_TRANSACTION COMMIT_TRANSACTION ROLLBACK (or ABORT) Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-19

Trasactio ad System Cocepts (cot d.) Figure 20.4 State trasitio diagram illustratig the states for trasactio executio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-20

The System Log System log keeps track of trasactio operatios Sequetial, apped-oly file Not affected by failure (except disk or catastrophic failure) Log buffer Mai memory buffer Whe full, appeded to ed of log file o disk Log file is backed up periodically Udo ad redo operatios based o log possible Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-21

Commit Poit of a Trasactio Occurs whe all operatios that access the database have completed successfully Ad effect of operatios recorded i the log Trasactio writes a commit record ito the log If system failure occurs, ca search for trasactios with recorded start_trasactio but o commit record Force-writig the log buffer to disk Writig log buffer to disk before trasactio reaches commit poit Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-22

DBMS-Specific Buffer Replacemet Policies Page replacemet policy Selects particular buffers to be replaced whe all are full Domai separatio (DS) method Each domai hadles oe type of disk pages Idex pages Data file pages Log file pages Number of available buffers for each domai is predetermied Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-23

DBMS-Specific Buffer Replacemet Policies (cot d.) Hot set method Useful i queries that sca a set of pages repeatedly Does ot replace the set i the buffers util processig is completed The DBMIN method Predetermies the patter of page refereces for each algorithm for a particular type of database operatio Calculates locality set usig query locality set model (QLSM) Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-24

20.3 Desirable Properties of Trasactios ACID properties Atomicity Trasactio performed i its etirety or ot at all Cosistecy preservatio Takes database from oe cosistet state to aother Isolatio Not iterfered with by other trasactios Durability or permaecy Chages must persist i the database Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-25

Desirable Properties of Trasactios (cot d.) Levels of isolatio Level 0 isolatio does ot overwrite the dirty reads of higher-level trasactios Level 1 isolatio has o lost updates Level 2 isolatio has o lost updates ad o dirty reads Level 3 (true) isolatio has repeatable reads I additio to level 2 properties Sapshot isolatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-26

20.4 Characterizig Schedules Based o Recoverability Schedule or history Order of executio of operatios from all trasactios Operatios from differet trasactios ca be iterleaved i the schedule Total orderig of operatios i a schedule For ay two operatios i the schedule, oe must occur before the other Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-27

Characterizig Schedules Based o Recoverability (cot d.) Two coflictig operatios i a schedule Operatios belog to differet trasactios Operatios access the same item X At least oe of the operatios is a write_item(x) Two operatios coflict if chagig their order results i a differet outcome Read-write coflict Write-write coflict Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-28

Characterizig Schedules Based o Recoverability (cot d.) Recoverable schedules Recovery is possible Norecoverable schedules should ot be permitted by the DBMS No committed trasactio ever eeds to be rolled back Cascadig rollback may occur i some recoverable schedules Ucommitted trasactio may eed to be rolled back Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-29

Characterizig Schedules Based o Recoverability (cot d.) Cascadeless schedule Avoids cascadig rollback Strict schedule Trasactios ca either read or write a item X util the last trasactio that wrote X has committed or aborted Simpler recovery process Restore the before image Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-30

20.5 Characterizig Schedules Based o Serializability Serializable schedules Always cosidered to be correct whe cocurret trasactios are executig Places simultaeous trasactios i series Trasactio T 1 before T 2, or vice versa Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-31

Figure 20.5 Examples of serial ad oserial schedules ivolvig trasactios T1 ad T2 (a) Serial schedule A: T1 followed by T2 (b) Serial schedule B: T2 followed by T1 (c) Two oserial schedules C ad D with iterleavig of operatios Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-32

Characterizig Schedules Based o Serializability (cot d.) Problem with serial schedules Limit cocurrecy by prohibitig iterleavig of operatios Uacceptable i practice Solutio: determie which schedules are equivalet to a serial schedule ad allow those to occur Serializable schedule of trasactios Equivalet to some serial schedule of same trasactios Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-33

Characterizig Schedules Based o Serializability (cot d.) Result equivalet schedules Produce the same fial state of the database May be accidetal Caot be used aloe to defie equivalece of schedules Figure 20.6 Two schedules that are result equivalet for the iitial value of X = 100 but are ot result equivalet i geeral Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-34

Characterizig Schedules Based o Serializability (cot d.) Coflict equivalece Relative order of ay two coflictig operatios is the same i both schedules Serializable schedules Schedule S is serializable if it is coflict equivalet to some serial schedule S. Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-35

Characterizig Schedules Based o Serializability (cot d.) Testig for serializability of a schedule Algorithm 20.1 Testig coflict serializability of a schedule S Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-36

Characterizig Schedules Based o Serializability (cot d.) Figure 20.7 Costructig the precedece graphs for schedules A to D from Figure 20.5 to test for coflict serializability (a) Precedece graph for serial schedule A (b) Precedece graph for serial schedule B (c) Precedece graph for schedule C (ot serializable) (d) Precedece graph for schedule D (serializable, equivalet to schedule A) Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-37

How Serializability is Used for Cocurrecy Cotrol Beig serializable is differet from beig serial Serializable schedule gives beefit of cocurret executio Without givig up ay correctess Difficult to test for serializability i practice Factors such as system load, time of trasactio submissio, ad process priority affect orderig of operatios DBMS eforces protocols Set of rules to esure serializability Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-38

View Equivalece ad View Serializability View equivalece of two schedules As log as each read operatio of a trasactio reads the result of the same write operatio i both schedules, the write operatios of each trasactio must produce the same results Read operatios said to see the same view i both schedules View serializable schedule View equivalet to a serial schedule Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-39

View Equivalece ad View Serializability (cot d.) Coflict serializability similar to view serializability if costraied write assumptio (o blid writes) applies Ucostraied write assumptio Value writte by a operatio ca be idepedet of its old value Debit-credit trasactios Less-striget coditios tha coflict serializability or view serializability Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-40

20.6 Trasactio Support i SQL No explicit Begi_Trasactio statemet Every trasactio must have a explicit ed statemet COMMIT ROLLBACK Access mode is READ ONLY or READ WRITE Diagostic area size optio Iteger value idicatig umber of coditios held simultaeously i the diagostic area Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-41

Trasactio Support i SQL (cot d.) Isolatio level optio Dirty read Norepeatable read Phatoms Table 20.1 Possible violatios based o isolatio levels as defied i SQL Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-42

Trasactio Support i SQL (cot d.) Sapshot isolatio Used i some commercial DBMSs Trasactio sees data items that it reads based o the committed values of the items i the database sapshot whe trasactio starts Esures phatom record problem will ot occur Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-43

20.7 Summary Sigle ad multiuser database trasactios Ucotrolled executio of cocurret trasactios System log Failure recovery Committed trasactio Schedule (history) defies executio sequece Schedule recoverability Schedule equivalece Serializability of schedules Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 20-44