Chapter 15 Transaction Management. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Transaction basics Concurrency.

Slides:



Advertisements
Similar presentations
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Advertisements

CSC271 Database Systems Lecture # 32.
Transaction Management Transparencies
Recovery CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
More on transactions…. Dealing with concurrency (OR: how to handle the pressure!) Locking Timestamp ordering Multiversion protocols Optimistic protocols.
Transaction Management and Concurrency Control
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
10 1 Chapter 10 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Chapter 17: Transaction Management
What is a Transaction? Logical unit of work
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
Transaction Management
1 Transaction Management Database recovery Concurrency control.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 15 Transaction Management.
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management and Concurrency Control
Transaction Management Chapter 9. What is a Transaction? A logical unit of work on a database A logical unit of work on a database An entire program An.
1 IT420: Database Management and Organization Transactions 31 March 2006 Adina Crăiniceanu
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
DBSQL 7-1 Copyright © Genetic Computer School 2009 Chapter 7 Transaction Management, Database Security and Recovery.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
1 Transaction Management Overview Chapter Transactions  A transaction is the DBMS’s abstract view of a user program: a sequence of reads and writes.
Data Concurrency Control And Data Recovery
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Chapterb19 Transaction Management Transaction: An action, or series of actions, carried out by a single user or application program, which reads or updates.
Database Design, Application Development, and Administration, 5 th Edition Copyright © 2011 by Michael V. Mannino. All rights reserved. Chapter 15 Transaction.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
1 Chapter 20 Transaction Management Transparencies Last Updated: 17 th March 2011 By M. Arief
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
Chapter 15 Recovery. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.15-2 Topics in this Chapter Transactions Transaction Recovery System.
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
The Relational Model1 Transaction Processing Units of Work.
XA Transactions.
Database Systems Recovery & Concurrency Lecture # 20 1 st April, 2011.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
Section 06 (a)RDBMS (a) Supplement RDBMS Issues 2 HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Recovery technique. Recovery concept Recovery from transactions failure mean data restored to the most recent consistent state just before the time of.
Module 11: Managing Transactions and Locks
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
18 September 2008CIS 340 # 1 Last Covered (almost)(almost) Variety of middleware mechanisms Gain? Enable n-tier architectures while not necessarily using.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Transactions and Concurrency Control. 2 What is a Transaction?  Any action that reads from and/or writes to a database may consist of  Simple SELECT.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
9 1 Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Functions of a Database Management System
Transaction Management Transparencies
Transaction Management
Transaction Properties
Chapter 10 Transaction Management and Concurrency Control
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Transaction management
Transactions and Concurrency
Presentation transcript:

Chapter 15 Transaction Management

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Transaction basics Concurrency control Recovery management Transaction design issues Workflow management

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Definition Supports daily operations of an organization Collection of database operations Reliably and efficiently processed as one unit of work No lost data –Interference among multiple users –Failures

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Airline Transaction Example START TRANSACTION Display greeting Get reservation preferences from user SELECT departure and return flight records If reservation is acceptable then UPDATE seats remaining of departure flight record UPDATE seats remaining of return flight record INSERT reservation record Print ticket if requested End If On Error: ROLLBACK COMMIT

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Properties Atomic: all or nothing Consistent: database must be consistent before and after a transaction Isolated: no unwanted interference from other users Durable: database changes are permanent after the transaction completes

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Processing Services Concurrency control Recovery management Service characteristics –Transparent –Consume significant resources –Significant cost component

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Concurrency Control Problem definition Concurrency control problems Concurrency control tools

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Concurrency Control Problem Objective: –Maximize work performed –Throughput: number of transactions processed per unit time Constraint: –No interference: serial effect –Interference occurs on commonly manipulated data known as hot spots

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Lost Update Problem

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Uncommitted Dependency Problem

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Inconsistent Retrieval Problems Interference causes inconsistency among multiple retrievals of a subset of data Incorrect summary Phantom read Non repeatable read

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Incorrect Summary Problem

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Locking Fundamentals Fundamental tool of concurrency control Obtain lock before accessing an item Wait if a conflicting lock is held –Shared lock: conflicts with exclusive locks –Exclusive lock: conflicts with all other kinds of locks Concurrency control manager maintains the lock table

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Locking Granularity

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Deadlock (Mutual Waiting)

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Deadlock Resolution Detection –Can involve significant overhead –Not widely used Timeout –Waiting limit –Can abort transactions that are not deadlocked –Widely used although timeout interval is difficult to determine

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Two Phase Locking (2PL) Protocol to prevent lost update problems All transactions must follow Conditions –Obtain lock before accessing item –Wait if a conflicting lock is held –Cannot obtain new locks after releasing locks

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 2PL Implementation

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Optimistic Approaches Assumes conflicts are rare No locks Check for conflicts –After each read and write –At end of transaction Evaluation –Less overhead –More variability

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Recovery Management Device characteristics and failure types Recovery tools Recovery processes

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Storage Device Basics Volatile: loses state after a shutdown Nonvolatile: retains state after a shutdown Nonvolatile is more reliable than volatile but failures can cause loss of data Use multiple levels and redundant levels of nonvolatile storage for valuable data

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Failure Types Local –Detected and abnormal termination –Limited to a single transaction Operating System –Affects all active transactions –Less common than local failures Device –Affects all active and past transactions –Least common

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Log History of database changes Large storage overhead Operations –Undo: revert to previous state –Redo: reestablish a new state Fundamental tool of recovery management

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Log Example

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Checkpoints Reduces restart work but adds overhead –Checkpoint log record –Write log buffers and database buffers Checkpoint interval: time between checkpoints Types of checkpoints –Cache consistent –Fuzzy

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Other Recovery Tools Force writing –Checkpoint time –End of transaction Database backup –Complete –Incremental

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Recovery from a Media Failure Restore database from the most recent backup Redo all committed transactions since the most recent backup Restart active transactions

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Recovery Timeline

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Recovery Processes Depend on timing of database writes Immediate update approach: –Before commit –Log records written first (write-ahead log protocol) Deferred update approach –After commit –Undo operations not needed

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Immediate Update Recovery

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Deferred Update Recovery

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Design Issues Transaction boundary Isolation levels Deferred constraint checking Savepoints

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Boundary Decisions Division of work into transactions Objective: minimize transaction duration Constraint: enforcement of important integrity constraints Transaction boundary decision can affect hot spots

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Registration Form Example

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Transaction Boundary Choices One transaction for the entire form One transaction for the main form and one transaction for all subform records One transaction for the main form and separate transactions for each subform record

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Isolation Levels Degree to which a transaction is separated from the actions of other transactions Balance concurrency control overhead with interference problems Some transactions can tolerate uncommitted dependency and inconsistent retrieval problems Specify using the SET TRANSACTION statement

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. SQL Isolation Levels LevelXLocksSLocksPLocksInterference Read uncommitted None Uncommitted dependency Read committed LongShortNoneAll except uncommitted dependency Repeatable read Long Short (S), Long (X) Phantom reads SerializableLong None

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Scholar’s Lost Update Transaction ATimeTransaction B Obtain S lock on SRT1T1 Read SR (10)T2T2 Release S lock on SRT3T3 If SR > 0 then SR = SR -1T4T4 T5T5 Obtain S lock on SR T6T6 Read SR (10) T7T7 Release S lock on SR T8T8 If SR > 0 then SR = SR -1 Obtain X lock on SRT9T9 Write SR (9)T 10 CommitT 11 T 12 Obtain X lock on SR T 13 Write SR (9)

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Integrity Constraint Timing Most constraints checked immediately Can defer constraint checking to EOT SQL SET CONSTRAINTS statement

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Save Points Some transactions have tentative actions SAVEPOINT statement determines intermediate points ROLLBACK to specified save points

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Workflow Management Workflow description Enabling technologies Advanced transaction management

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Workflows Set of tasks to accomplish a business process Human-oriented vs. computer-oriented –Amount of judgment –Amount of automation Task structure vs. task complexity –Relationships among tasks –Difficulty of performing individual tasks

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Enabling Technologies Distributed object management –Many kinds of non traditional data –Data often dispersed in location Workflow modeling –Specification –Simulation –Optimization

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Advanced Transaction Management Conversational transactions Transactions with complex structure Transactions involving legacy systems Compensating transactions More flexible transaction processing

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Summary Transaction: user-defined collection of work DBMSs support ACID properties Knowledge of concurrency control and recovery important for managing databases Transaction design issues are important Transaction processing is an important part of workflow management