Assignment 6 - Solution Problem 1 Suppose a transaction sets an intention-write lock on a file and later sets a write lock on a record of the file. Is.

Slides:



Advertisements
Similar presentations
Chapter 16 Concurrency. Topics in this Chapter Three Concurrency Problems Locking Deadlock Serializability Isolation Levels Intent Locking Dropping ACID.
Advertisements

1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Chapter 15: Transactions Transaction Concept Transaction Concept Concurrent Executions Concurrent Executions Serializability Serializability Testing for.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 4: More on Locks Professor Chen Li.
1 CS216 Advanced Database Systems Shivnath Babu Notes 12: Concurrency Control (II)
Concurrency Control Amol Deshpande CMSC424. Approach, Assumptions etc.. Approach  Guarantee conflict-serializability by allowing certain types of concurrency.
Managing Hierarchies of Database Elements (18.6) 1 Presented by Sarat Dasika (114) February 16, 2012.
Revision Lecture Database Systems Michael Pound Stanislava Armstrong.
CSIS 7102 Spring 2004 Lecture 5 : Non-locking based concurrency control (and some more lock-based ones, too) Dr. King-Ip Lin.
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 Supplemental Notes: Practical Aspects of Transactions THIS MATERIAL IS OPTIONAL.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. –Because disk accesses are.
Quick Review of Apr 29 material
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
CONCURRENCY CONTROL SECTION 18.7 THE TREE PROTOCOL By : Saloni Tamotia (215)
Managing Hierarchies of Database Elements (18.6) -Neha Saxena Class Id: 214.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Distributed Systems Fall 2010 Transactions and concurrency control.
Transaction Management and Concurrency Control
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
Transaction Management and Concurrency Control
Transaction Management
CS514: Intermediate Course in Operating Systems Professor Ken Birman Ben Atkin: TA Lecture 7: Sept. 14.
18.8 Concurrency Control by Timestamps - Dongyi Jia - CS257 ID:116 - Spring 2008.
1 Concurrency Control. 2 Transactions A transaction is a list of actions. The actions are reads (written R T (O)) and writes (written W T (O)) of database.
© 1997 UW CSE 11/13/97N-1 Concurrency Control Chapter 18.1, 18.2, 18.5, 18.7.
1 IT420: Database Management and Organization Transactions 31 March 2006 Adina Crăiniceanu
Exercises for Chapter 16: Transactions and Concurrency Control
Databases Illuminated
Department of Computer Science and Engineering, HKUST 1 More on Isolation.
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Concurrency and Transaction Processing. Concurrency models 1. Pessimistic –avoids conflicts by acquiring locks on data that is being read, so no other.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Chapter 11 Concurrency Control. Lock-Based Protocols  A lock is a mechanism to control concurrent access to a data item  Data items can be locked in.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Assignment 3 -- Solution 1. Problem 1 H 1 : r 1 [y] r 1 [x] r 2 [x] w 1 [y] c 1 w 2 [y] c 2 H 1 is normally-strict two-phase locked: rl 1 [y] r 1 [y]
1 Concurrency Control II: Locking and Isolation Levels.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 136 Database Systems I SQL Modifications and Transactions.
XA Transactions.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
1 Concurrency control lock-base protocols timestamp-based protocols validation-based protocols Ioan Despi.
1 CSE 480: Database Systems Lecture 24: Concurrency Control.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
Timestamp-based Concurrency Control
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
1 Controlled concurrency Now we start looking at what kind of concurrency we should allow We first look at uncontrolled concurrency and see what happens.
SHUJAZ IBRAHIM CHAYLASY GNOPHANXAY FIT, KMUTNB JANUARY 05, 2010 Distributed Database Systems | Dr.Nawaporn Wisitpongphan | KMUTNB Based on article by :
Database Isolation Levels. Reading Database Isolation Levels, lecture notes by Dr. A. Fekete, resentation/AustralianComputer.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
Concurrency Control A database must provide a mechanism that will ensure that all possible schedules are either conflict or view serializable, and are.
Transaction Management
CS422 Principles of Database Systems Concurrency Control
Extra slide #3.
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
J.N GRAY R.A LORIE IBM RESEARCH LAB, SAN JOSE, CALIFORNIA
Basic Two Phase Locking Protocol
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Transaction management
SE305 Database System Technology
Submitted to Dr. Badie Sartawi Submitted by Nizar Handal Course
Presentation transcript:

Assignment 6 - Solution Problem 1 Suppose a transaction sets an intention-write lock on a file and later sets a write lock on a record of the file. Is it safe for the transaction to release the intention-write lock before it commits? Why? No it’s not safe. Suppose record x is contained in file F. Consider the following execution: iwl 1 [F] wl 1 [x] w 1 [x] iwu 1 [F] rl 2 [F] r 2 [x] w 1 [x] wu 1 [x] c 1 ru 2 [F] c 2 Transaction T 1 writes x twice, once before r 2 [x] and once afterwards, so the result isn’t serializable.

Problem 2 The multi-granularity locking protocol requires that if a transaction has a w or iw lock on a data item x, then it must have an iw lock on x’s parent. 2.A. Is it correct for a transaction to hold an r lock on x’s parent instead? Either explain why it’s correct or give an example where it fails. No, it is incorrect. This would allow: T 1 to read lock file F (giving it permission to read every record in F), T 2 to read lock F and write lock a record in F, such as x. Thus T 1 would implicitly have a read lock on x that conflicts with T 2 ’s write lock on x.

2.B. Redo question (2.A), replacing “r lock” by “w lock”. Is it correct for a transaction to hold an w lock on x’s parent instead? Yes, it is correct. Assuming the given protocol is correct using iw locks, then w locks must work too w lock is strictly stronger than an iw lock. By “stronger,” we mean that any lock type that conflicts with an iw lock also conflicts with a w lock. You might think it’s incorrect because it needlessly prevents certain operations from running. This is a performance problem, but not incorrect, in the sense of breaking a conflict or an ACID property.

2.C. Assuming the lock graph is a tree, suggest a case where it would be useful to set such a w lock as in (2.B) (whether or not it’s correct). In cases where the data manager would escalate fine-grained w locks to coarse-grained locks, then using the coarse-grained w as parent will perform slightly better by avoiding the escalation cost and the cost of needlessly setting the fine-grained locks before escalating.

Problem 3 Consider the following database table, which supports a multiversion concurrency control. Suppose the commit list contains {1,2,3,4,6} and there are no active transactions. TIDPrev TIDAccount#Balance 1Null Null Null12500

3.A. What is the state of the table after running the following transaction?: TID=8: Increment the balance of account 10 by 100; Delete account 12; Insert account 13 with balance 700. The database state after transaction 8 commits TIDPrev TIDAccount#Balance 1Null Null Null deleted 8Null13700 TIDPrev TIDAccount#Balance 1Null Null Null12500

3.B. Suppose a read-only query with TID=7 reads all the accounts. It starts executing before executing transaction 8 starts executing and finishes after transaction 8 commits (same transaction 8 as part (a)). Which versions of which rows does it read?

3.B. When it started executing, transaction 7 read the following commit list: {1,2,3,4,6}. It read the following: version TID 3 of Account 10, version TID 4 of Account 11 (because 5 didn’t commit) version TID 6 of account 12. It does not see any of transaction 8’s updates because transaction 8 was not on the commit list when it started. TIDPrev TIDAccount#Balance 1Null Null Null deleted 8Null13700

3.C. After transactions 7 and 8 have finished and no other transactions are active, suppose we garbage collect all of the versions that aren’t needed. Assuming transaction ids increase monotonically with respect time, what does the table look like after the garbage collection step? The garbage collector keeps the last committed update of each account: TIDPrev TIDAccount#Balance 8Null Null Null13700 TIDPrev TIDAccount#Balance 1Null Null Null deleted 8Null13700

Problem 4 Suppose file F contains a sequence of fixed-length records, and F’s descriptor includes a count of the number of records in F, which is used to find the end of F. Consider the following two transactions: T 1 : Scan F, returning all the records in F Read(x) T 2 : Insert a record into F Write(x) Data item x is not in F. Both transactions are two-phase locked (locking records in F and x), but neither transaction locks count.

4.A. Given an example of a non-serializable execution of T 1 and T 2. Explain why it’s non- serializable. 1.T 1 : Scan F, returning all the records in F 2.T 2 : Insert a record into F 3.T 2 : Write(x) 4.Commit 2 5.T 1 : Read(x) The first two operations imply and T 1 precedes T 2, but since they don’t lock count, the first operation doesn’t cause the second one to be delayed. The third and fifth operations on x conflict, which imply that T 2 precedes T 1. So the execution isn’t SR.

4.B. Explain why this is an example of the phantom problem. T 1 : Scan F, returning all the records in F Read(x) T 2 : Insert a record into F Write(x) T 2 ’s insertion into F is a phantom record. T 1 ’s scan doesn’t see the record, but T 1 ’s Read(x) indirectly sees the result in data item x (assuming the value of x is a function of the records in F).