CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu. Solution Assignment 5

Similar documents
Lecture 7: Concurrency control. Rasmus Pagh

Concurrency Control. Module 6, Lectures 1 and 2

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

Transaction Management Overview

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

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

Database Tuning and Physical Design: Execution of Transactions

Database Sample Examination

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

Transactional properties of DBS

Concurrency Control: Locking, Optimistic, Degrees of Consistency

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

CS 245 Final Exam Winter 2013

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

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

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

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

Transactions. SET08104 Database Systems. Napier University

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

Concurrency control. Concurrency problems. Database Management System

Figure 19.1 Interleaved processing versus parallel processing of concurrent transactions.

CMSC724: Concurrency

Transactions and the Internet

Introduction to Database Systems CS4320. Instructor: Christoph Koch CS

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

b. Examine the following histories. Draw their serialization graph and identify which of them is serializable given reasons.

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

CHAPTER 6: DISTRIBUTED FILE SYSTEMS

Ph.D. Thesis Proposal Database Replication in Wide Area Networks

Part I: Entity Relationship Diagrams and SQL (40/100 Pt.)

Logistics. Database Management Systems. Chapter 1. Project. Goals for This Course. Any Questions So Far? What This Course Cannot Do.

Textbook and References

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

Chapter 6 The database Language SQL as a tutorial

8 9 +

THE UNIVERSITY OF TRINIDAD & TOBAGO

The Joint Venture Partnership

Distributed Databases

INTRODUCTION TO DATABASE SYSTEMS

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

Serializable Isolation for Snapshot Databases

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

Distributed Transactions

Synchronization and recovery in a client-server storage system

Real Time Database Systems

RD 1000 Clinic Back up Training

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

Code Aware Resource Scheduling

Transaction Processing Monitors

Generalized Isolation Level Definitions

Chapter 10. Backup and Recovery

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

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

Database Concurrency Control and Recovery. Simple database model

Academic Standards for Economics

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Database Replication Techniques: a Three Parameter Classification

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

Chapter 10: Distributed DBMS Reliability

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

Distributed Databases: what is next?

Sign-up Tool User Manual

Serial Communications / Protocol in AirTest Products

Postgres-R(SI): Combining Replica Control with Concurrency Control based on Snapshot Isolation

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

ILCO Cylinders. Cams and Tailpieces. Keyways. Finish Codes. 1 Standard (863G) Composite NB HR1. Composite NA R1064E. 2 Adams Rite (863A) Arrow AA 1179

PostgreSQL Concurrency Issues

Cloud DBMS: An Overview. Shan-Hung Wu, NetDB CS, NTHU Spring, 2015

Entangled Transactions. Nitin Gupta, Milos Nikolic, Sudip Roy, Gabriel Bender, Lucja Kot, Johannes Gehrke, Christoph Koch

Audio Tone Control Using The TLC074 Operational Amplifier

RELATIONAL DATABASE DESIGN

Pronto: High Availability for Standard Off-the-shelf Databases

APNT#1168 Modbus - Establishing Communications Hints

User Manual Software for DSL Digital Speed Switch

Online, Asynchronous Schema Change in F1

TECHNICAL REPORT. DSL Forum TR-034. Alternative OAM Communications Channel Across the U interface. May 2000

Transactions and Recovery. Database Systems Lecture 15 Natasha Alechina

CSE 444 Midterm Test

Precision Leaded Resistors

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Chapter 3 - Data Replication and Materialized Integration

An Overview of Distributed Databases

CS143 Notes: Normalization Theory

Programming and Using the Courier V.Everything Modem for Remote Operation of DDF6000

Transcription:

CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu Solution Assignment 5 Total marks: 200 (20 % of the assignments) Due date: December 2, 2009 Problem 5.1 (50 marks) For each of the following schedules, state whether they are serializable and whether they are conflict-serializable. For each schedule, draw the corresponding precedence graph. If the schedule is conflict-serializable, show all the conflict-equivalent serial schedules. If the schedule is not serializable, provide an initial DB state and some semantics (pseudo-code) for the transactions for which no serial schedule has the same net effect. a) S = r2(a) w2(a) P(S) = T2 T1 T2 The schedule is not conflict-serializable, since there is a cycle in the precedence graph. To see that the schedule is also not serializable, consider the following example: A = 10, T1: A:=A*10, T2: A:=A*10 The above interleaved schedule results in A = 100, but both serial schedules result in A = 1000. b) S = r2(b) w3(a) r2(a) r1(b) P(S) = T1 T3 T2 The schedule is conflict-serializable, since its precedence graph does not contain any cycle. The only conflict-equivalent serial schedule is T1, T3, T2. The schedule is also serializable, since conflict-serializability implies serializability. c) S = w2(a) r3(a) P(S) = T1 T2 T1 T3 The schedule is not conflict-serializable, because its precedence graph is cyclic.

To see that the schedule is also not serializable, consider the following example: A = 10, T1: A:= A * 10, T2: A:= 1000, T3: PRINT(A) S results in A = 100 and PRINT 100. All possible serial schedules have a different net effect as follows: T1, T2, T3: A = 1000, PRINT 1000 T1, T3, T2: A = 1000, PRINT 100 T2, T1, T3: A = 10000, PRINT 10000 T2, T3, T1: A = 10000, PRINT 1000 T3, T1, T2: A = 1000, PRINT 10 T3, T2, T1: A = 10000, PRINT 10. Problem 5.2 (50 marks) Show all the conflict-serializable schedules of the following transactions T1 and T2. Explain why these are all such schedules. a) T1: r1(b) w1(b) T2: r2(b) w2(b) r2(a) w2(a). conflict-equivalent to T1, T2 r1(b) w1(b) r2(b) w2(b) r2(a) w2(a) This is the serial schedule T1, T2. There are no other conflict-equivalent schedules, since there is no non-conflicting swap of adjacent actions in this schedule: we cannot swap actions within a transaction, and w1(b) r2(b) cannot be swapped, because they are both manipulating the same database element and one of them is a write. conflict-equivalent to T2, T1 r2(b) w2(b) r2(a) w2(a) r1(b) w1(b) This is the serial schedule T2, T1. There are no other conflict-equivalent schedules, since there is no non-conflicting swap of adjacent actions in this schedule: we cannot swap actions within a transaction, and w2(a) cannot be swapped, because they are both manipulating the same database element and one of them is a write. b) T1: r1(b) w1(b) T2: r2(a) w2(a) r2(b) w2(b) Note that the action in bold font is the one that has been moved forward in the last swap. conflict-equivalent to T1, T2 r1(b) w1(b) r2(a) w2(a) r2(b) w2(b)

r1(b) r2(a) w1(b) w2(a) r2(b) w2(b) r1(b) r2(a) w2(a) w1(b) r2(b) w2(b) r2(a) r1(b) w1(b) w2(a) r2(b) w2(b) r2(a) r1(b) w2(a) w1(b) r2(b) w2(b) r2(a) w2(a) r1(b) w1(b) r2(b) w2(b) No further swap is possible, since (1) we cannot swap actions of the same transaction and (2) r2(a) and w1(b) r2(b) are both manipulating the same database element and one of them is a write. conflict-equivalent to T2, T1 r2(a) w2(a) r2(b) w2(b) r1(b) w1(b) r2(a) w2(a) r2(b) w2(b) r1(b) w1(b) r2(a) w2(a) r2(b) w2(b) r1(b) w1(b) r2(a) w2(a) r2(b) w2(b) r1(b) w1(b) r2(a) w2(a) r2(b) w2(b) r1(b) w1(b) r2(a) w2(a) r2(b) w2(b) r1(b) w1(b) No further swap is possible, since (1) we cannot swap actions of the same transaction and (2) w2(a) and w2(b) r1(b) are both manipulating the same database element and one of them is a write. Problem 5.3 (40 marks) Consider the following schedules of transactions T1, T2 and T3. Insert shared and exclusive lock actions as well as unlock actions and modify the schedule where necessary. Place a shared or exclusive lock immediately before the read or write action that requires it. Place the necessary unlocks at the end of a transaction. If a deadlock occurs, abort the participating transaction that started last, release all its locks and re-start that transaction after all the other participating transactions have committed. Show the complete schedules satisfying the 2PL protocol. a) r2(b) r3(c) r1(b) r2(c) r3(d) w2(b) w3(c) T1 T2 T3 sl-2(b) r2(b) sl-3(c) r3(c) sl-1(b) r1(b) sl-2(c) r2(c) sl-3(d) r3(d) T2 has to wait until T1 returns the S lock on B T3 has to wait until T2 returns the S lock on C

xl-1(a) u1(b) xl-2(b) w2(b) u2(b) u2(c) xl-3(c) w3(c) u3(c) u3(d) b) r2(b) r3(c) r1(b) r2(c) r3(a) w2(b) w3(c) T1 T2 T3 sl-2(b) r2(b) sl-3(c) r3(c) sl-1(b) r1(b) xl-1(a) xl-1(a) u1(b) sl-2(c) r2(c) xl-2(b) w2(b) u2(b) u2(c) sl-3(a) r3(a) xl-3(c) abort u3(a) u3(c) sl-3(c) r3(c) sl-3(a) T1 has to wait until T3 releases the S lock on A T2 has to wait until T1 releases the S lock on B T3 has to wait until T2 releases the S lock on C restart T3

r3(a) xl-3(c) w3(c) u3(a) u3(c) Note that the lock requests in bold font cannot be granted right away, and the requesting transactions have to wait. Problem 5.4 (60 marks) Provide one example schedule (including the commits) of two transactions (that both commit, i.e. no aborts involved) with each of the following properties. In concurrency control by validation, suppose that validation is performed at the time of the commit. To show that a schedule validates or does not validate, show the read and write sets for the two transactions and show that both validation rules are satisfies or list the validation rule violated. To show that a schedule satisfies or does not satisfy the 2PL protocol, show the modified schedule after inserting shared and exclusive lock actions right before the corresponding read / write action and unlock actions right before the commit. a) The schedule is allowed by 2PL, but not by concurrency control by validation. T1: commit T2: r2(b) w2(b) r2(a) w2(a) commit To see that the schedule is allowed by 2PL: T1 T2 xl-1(a) commit sl-2(b) r2(b) xl-2(b) w2(b) sl-2(a) r2(a) xl-2(a) w2(a) u2(a)

u2(b) commit The schedule does not validate, since it violates the first validation rule: RS(T1) = {A}, WS(T1) = {A} RS(T2) = {A, B}, WS(T2) = {A, B} FIN(T1) > START(T2) and RS( T2) WS ( T1) { A}. Note that FIN(T1) > VAL(T1) = COMMIT(T1) > START(T2). b) The schedule is allowed by concurrency control by validation, but not by 2PL. T1: w1(b) r1(c) commit T2: w2(a) r2(c) w2(c) commit To see that the schedule validates: RS(T1) = {A, C}, WS(T1) = {B} RS(T2) = {C}, WS(T2) = {A, C} T1 trivially validates, because there is no other transaction that is validated earlier. FIN(T1) > START(T2) holds, but RS( T2) WS( T1). We do not know whether FIN(T1) > VAL(T2), but anyway WS ( T2) WS ( T1). Therefore, T2 also validates. To see that the schedule is not allowed by 2PL: T1 T2 xl-1(b) w1(b) sl-1(c) r1(c) u1(b) xl-2(a) T2 has to wait until T1 releases the S lock on A u1(c) w2(a) commit sl-2(c) r2(c) xl-2(c) w2(c) commit