Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items.

Similar documents
Advanced Databases. Lecture 9- Concurrency Control (continued) Masood Niazi Torshiz Islamic Azad University- Mashhad Branch

! A lock is a mechanism to control concurrent access to a data item! Data items can be locked in two modes :

Chapter 12 : Concurrency Control

Chapter 13 : Concurrency Control

Lecture 22 Concurrency Control Part 2

Chapter 15 : Concurrency Control

2 nd Semester 2009/2010

Comp 5311 Database Management Systems. 14. Timestamp-based Protocols

A lock is a mechanism to control concurrent access to a data item Data items can be locked in two modes:

CSIT5300: Advanced Database Systems

Multiversion Schemes to achieve Snapshot Isolation Timestamped Based Protocols

Lecture 13 Concurrency Control

Chapter 16 : Concurrency Control

Concurrency Control! Snapshot isolation" q How to ensure serializability and recoverability? " q Lock-Based Protocols" q Other Protocols"

Lecture 21 Concurrency Control Part 1

Concurrency Control. Concurrency Control Ensures interleaving of operations amongst concurrent transactions result in serializable schedules

Concurrency Control Overview. COSC 404 Database System Implementation. Concurrency Control. Lock-Based Protocols. Lock-Based Protocols (2)

Chapter 10: Concurrency Control! Chapter 10 : Concurrency Control! Intuition of Lock-based Protocols! Lock-Based Protocols!

Chapter 10 : Concurrency Control!

References. Concurrency Control. Administração e Optimização de Bases de Dados 2012/2013. Helena Galhardas e

Chapter 10 : Concurrency Control

mywbut.com Concurrency Control

Transaction Management

Multiversion schemes keep old versions of data item to increase concurrency. Multiversion Timestamp Ordering Multiversion Two-Phase Locking Each

Transactions and Concurrency Control. Dr. Philip Cannata

Chapter 15: Transactions

Advanced Databases (SE487) Prince Sultan University College of Computer and Information Sciences. Dr. Anis Koubaa. Spring 2014

CMSC 424 Database design Lecture 22 Concurrency/recovery. Mihai Pop

Chapter 13: Transactions

CSIT5300: Advanced Database Systems

BİL 354 Veritabanı Sistemleri. Transaction (Hareket)

Transaction Management. Chapter 14

CS 370 Concurrency worksheet. T1:R(X); T2:W(Y); T3:R(X); T2:R(X); T2:R(Z); T2:Commit; T3:W(X); T3:Commit; T1:W(Y); Commit

Transactions. Prepared By: Neeraj Mangla

Chapter 15: Transactions

Transactions These slides are a modified version of the slides of the book Database System Concepts (Chapter 15), 5th Ed

Conflict serializability

Transaction Concept. Two main issues to deal with:

Introduction Conflict Serializability. Testing for Serializability Applications Scope of Research

Database System Concepts

Transaction Processing: Concurrency Control. Announcements (April 26) Transactions. CPS 216 Advanced Database Systems

Chapter 14: Transactions

ICOM 5016 Database Systems. Chapter 15: Transactions. Transaction Concept. Chapter 15: Transactions. Transactions

Transaction Concept. Chapter 15: Transactions. Example of Fund Transfer. ACID Properties. Example of Fund Transfer (Cont.)


Database System Concepts

Concurrency Control. Transaction Management. Lost Update Problem. Need for Concurrency Control. Concurrency control

Concurrency Control. Data Base Management Systems. Inherently Concurrent Systems: The requirements

Database System Concepts

Chapter 5. Concurrency Control Techniques. Adapted from the slides of Fundamentals of Database Systems (Elmasri et al., 2006)

Transactions. Lecture 8. Transactions. ACID Properties. Transaction Concept. Example of Fund Transfer. Example of Fund Transfer (Cont.

CS322: Database Systems Transactions

T ransaction Management 4/23/2018 1

Transaction Processing: Basics - Transactions

Goal of Concurrency Control. Concurrency Control. Example. Solution 1. Solution 2. Solution 3

Transactions. Silberschatz, Korth and Sudarshan

UNIT 4 TRANSACTIONS. Objective

Chapter 18 Concurrency Control Techniques

Lecture 20 Transactions

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

Concurrency Control CHAPTER 17 SINA MERAJI

Distributed Transaction Management. Distributed Database System

Deadlock Prevention (cont d) Deadlock Prevention. Example: Wait-Die. Wait-Die

Database Management Systems 2010/11

Chapter 9: Concurrency Control

Database Management Systems

CS Reading Packet: "Transaction management, part 2"

Chapter 14: Transactions

Roadmap of This Lecture

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

Concurrency. Consider two ATMs running in parallel. We need a concurrency manager. r1[x] x:=x-250 r2[x] x:=x-250 w[x] commit w[x] commit

UNIT-IV TRANSACTION PROCESSING CONCEPTS

TRANSACTION PROCESSING CONCEPTS

Concurrency Control. R &G - Chapter 19

Concurrency Control. [R&G] Chapter 17 CS432 1

Chapter 9: Transactions

Concurrency Control. Conflict Serializable Schedules. Example. Chapter 17

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

Concurrency Control 9-1

Lecture 7: Transactions Concurrency Control

CHAPTER: TRANSACTIONS

Transactions and Concurrency Control

CSE 444: Database Internals. Lectures Transactions

Checkpoints. Logs keep growing. After every failure, we d have to go back and replay the log. This can be time consuming. Checkpoint frequently

References. Transaction Management. Database Administration and Tuning 2012/2013. Chpt 14 Silberchatz Chpt 16 Raghu

UNIT IV TRANSACTION MANAGEMENT

CS352 Lecture - Concurrency

Advances in Data Management Transaction Management A.Poulovassilis

Unit 10.5 Transaction Processing: Concurrency Zvi M. Kedem 1

Implementing Isolation

DB2 Lecture 10 Concurrency Control

More Concurrency. Database Systems Lecture 17 Natasha Alechina

Database design and implementation CMPSCI 645. Lectures 18: Transactions and Concurrency

Concurrency control CS 417. Distributed Systems CS 417

CSE 344 MARCH 9 TH TRANSACTIONS

Lecture 5: Transactions Concurrency Control. Wednesday October 26 th, 2011

Introduction to Data Management CSE 414

CS352 Lecture - Concurrency

Last Lecture. More Concurrency. Concurrency So Far. In This Lecture. Serialisability. Schedules. Database Systems Lecture 15

Distributed Databases Systems

Transcription:

Graph-based protocols are an alternative to two-phase locking Impose a partial ordering on the set D = {d 1, d 2,..., d h } of all data items. If d i d j then any transaction accessing both d i and d j must access d i before accessing d j. Implies that the set D may now be viewed as a directed acyclic graph, called a database graph. The tree-protocol is a simple kind of graph protocol.

Only exclusive locks are allowed. The first lock by T i may be on any data item. Subsequently, a data Q can be locked by T i only if the parent of Q is currently locked by T i. Data items may be unlocked at any time.

The tree protocol ensures conflict serializability as well as freedom from deadlock. Unlocking may occur earlier in the tree-locking protocol than in the two-phase locking protocol. shorter waiting times, and increase in concurrency protocol is deadlock-free, no rollbacks are required the abort of a transaction can still lead to cascading rollbacks. (this correction has to be made in the book also.) However, in the tree-locking protocol, a transaction may have to lock data items that it does not access. increased locking overhead, and additional waiting time potential decrease in concurrency Schedules not possible under two-phase locking are possible under tree protocol, and vice versa.

Each transaction is issued a timestamp when it enters the system. If an old transaction T i has time-stamp TS(T i ), a new transaction T j is assigned time-stamp TS(T j ) such that TS(T i ) <TS(T j ). The protocol manages concurrent execution such that the time-stamps determine the serializability order. In order to assure such behavior, the protocol maintains for each data Q two timestamp values: W-timestamp(Q) is the largest time-stamp of any transaction that executed write(q) successfully. R-timestamp(Q) is the largest time-stamp of any transaction that executed read(q) successfully.

The timestamp ordering protocol ensures that any conflicting read and write operations are executed in timestamp order. Suppose a transaction T i issues a read(q) 1. If TS(T i ) W-timestamp(Q), then T i needs to read a value of Q that was already overwritten. Hence, the read operation is rejected, and T i is rolled back. 2. If TS(T i ) W-timestamp(Q), then the read operation is executed, and R-timestamp(Q) is set to the maximum of R- timestamp(q) and TS(T i ).

Suppose that transaction T i issues write(q). If TS(T i ) < R-timestamp(Q), then the value of Q that T i is producing was needed previously, and the system assumed that that value would never be produced. Hence, the write operation is rejected, and T i is rolled back. If TS(T i ) < W-timestamp(Q), then T i is attempting to write an obsolete value of Q. Hence, this write operation is rejected, and T i is rolled back. Otherwise, the write operation is executed, and W- timestamp(q) is set to TS(T i ).

A partial schedule for several data items for transactions with timestamps 1, 2, 3, 4, 5 T 1 T 2 T 3 T 4 T 5 read(y) read(x) read(y) read(x) abort write(y) write(z) write(z) abort read(x) read(z) write(y) write(z)

The timestamp-ordering protocol guarantees serializability since all the arcs in the precedence graph are of the form: transaction with smaller timestamp transaction with larger timestamp Thus, there will be no cycles in the precedence graph Timestamp protocol ensures freedom from deadlock as no transaction ever waits. But the schedule may not be cascade-free, and may not even be recoverable.

Problem with timestamp-ordering protocol: Suppose T i aborts, but T j has read a data item written by T i Then T j must abort; if T j had been allowed to commit earlier, the schedule is not recoverable. Further, any transaction that has read a data item written by T j must abort This can lead to cascading rollback --- that is, a chain of rollbacks Solution: A transaction is structured such that its writes are all performed at the end of its processing All writes of a transaction form an atomic action; no transaction may execute while a transaction is being written A transaction that aborts is restarted with a new timestamp

Modified version of the timestamp-ordering protocol in which obsolete write operations may be ignored under certain circumstances. When T i attempts to write data item Q, if TS(T i ) < W- timestamp(q), then T i is attempting to write an obsolete value of {Q}. Hence, rather than rolling back T i as the timestamp ordering protocol would have done, this {write} operation can be ignored. Otherwise this protocol is the same as the timestamp ordering protocol. Thomas' Write Rule allows greater potential concurrency. Unlike previous protocols, it allows some view-serializable schedules that are not conflict-serializable.

Execution of transaction T i is done in three phases. 1. Read and execution phase: Transaction T i writes only to temporary local variables 2. Validation phase: Transaction T i performs a ``validation test'' to determine if local variables can be written without violating serializability. 3. Write phase: If T i is validated, the updates are applied to the database; otherwise, T i is rolled back. The three phases of concurrently executing transactions can be interleaved, but each transaction must go through the three phases in that order. Also called as optimistic concurrency control since transaction executes fully in the hope that all will go well during validation

Each transaction T i has 3 timestamps Start(T i ) : the time when T i started its execution Validation(T i ): the time when T i entered its validation phase Finish(T i ) : the time when T i finished its write phase Serializability order is determined by timestamp given at validation time, to increase concurrency. Thus TS(T i ) is given the value of Validation(T i ). This protocol is useful and gives greater degree of concurrency if probability of conflicts is low. That is because the serializability order is not pre-decided and relatively less transactions will have to be rolled back.

If for all T i with TS (T i ) < TS (T j ) either one of the following condition holds: finish(t i ) < start(t j ) start(t j ) < finish(t i ) < validation(t j ) and the set of data items written by T i does not intersect with the set of data items read by T j. then validation succeeds and T j can be committed. Otherwise, validation fails and T j is aborted. Justification: Either first condition is satisfied, and there is no overlapped execution, or second condition is satisfied and 1. the writes of T j do not affect reads of T i since they occur after T i has finished its reads. 2. the writes of T i do not affect reads of T j since T j does not read any item written by T i.

Example of schedule produced using validation T 14 T 15 read(b) read(a) (validate) display (A+B) read(b) B:- B-50 read(a) A:- A+50 (validate) write (B) write (A)

Allow data items to be of various sizes and define a hierarchy of data granularities, where the small granularities are nested within larger ones Can be represented graphically as a tree (but don't confuse with tree-locking protocol) When a transaction locks a node in the tree explicitly, it implicitly locks all the node's descendents in the same mode. Granularity of locking (level in tree where locking is done): fine granularity (lower in tree): high concurrency, high locking overhead coarse granularity (higher in tree): low locking overhead, low concurrency

The highest level in the example hierarchy is the entire database. The levels below are of type area, file and record in that order.

In addition to S and X lock modes, there are three additional lock modes with multiple granularity: intention-shared (IS): indicates explicit locking at a lower level of the tree but only with shared locks. intention-exclusive (IX): indicates explicit locking at a lower level with exclusive or shared locks shared and intention-exclusive (SIX): the subtree rooted by that node is locked explicitly in shared mode and explicit locking is being done at a lower level with exclusive-mode locks. intention locks allow a higher level node to be locked in S or X mode without having to check all descendent nodes.

The compatibility matrix for all lock modes is: IS IS IX S S IX X IX S S IX X

Transaction T i can lock a node Q, using the following rules: 1. The lock compatibility matrix must be observed. 2. The root of the tree must be locked first, and may be locked in any mode. 3. A node Q can be locked by T i in S or IS mode only if the parent of Q is currently locked by T i in either IX or IS mode. 4. A node Q can be locked by T i in X, SIX, or IX mode only if the parent of Q is currently locked by T i in either IX or SIX mode. 5. T i can lock a node only if it has not previously unlocked any node (that is, T i is two-phase). 6. T i can unlock a node Q only if none of the children of Q are currently locked by T i. Observe that locks are acquired in root-to-leaf order, whereas they are released in leaf-to-root order.