Transaction Processing Concepts

Slides:



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

CSC271 Database Systems Lecture # 32.
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
Transaction Management and Concurrency Control
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.
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
DBMS Functions Data, Storage, Retrieval, and Update
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 18.
Chapter 9 Transaction Management and Concurrency Control
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Transaction Management and Concurrency Control
Transaction. A transaction is an event which occurs on the database. Generally a transaction reads a value from the database or writes a value to the.
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 © Prentice Hall, 2002 Chapter 12: Data and Database Administration Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
1 IT420: Database Management and Organization Transactions 31 March 2006 Adina Crăiniceanu
© 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 CHAPTER 11: DATA AND DATABASE ADMINISTRATION Modern Database Management 11 th Edition Jeffrey.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
1 Transactions BUAD/American University Transactions.
Recovery & Concurrency Control. What is a Transaction?  A transaction is a logical unit of work that must be either entirely completed or aborted. 
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation and Management Peter Rob & Carlos Coronel.
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Ch 10: Transaction Management and Concurrent Control.
1 Transactions Chapter Transactions A transaction is: a logical unit of work a sequence of steps to accomplish a single task Can have multiple.
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
Concurrency Control in Database Operating Systems.
Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation and Management Peter Rob & Carlos Coronel.
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
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.
TM 13-1 Copyright © 1999 Addison Wesley Longman, Inc. Data and Database Administration.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
CSC 240 (Blum)1 Database Transactions. CSC 240 (Blum)2 Transaction  A transaction is an interaction between a user (or application) and a database. A.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Transaction Management and Concurrent Control
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.
10 Transaction Management and Concurrency Control MIS 304 Winter 2005.
©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.
9 1 Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
CSC314 Day 16 Transaction processing Concurrency Control 1.
Copyright © 2016 Pearson Education, Inc. CHAPTER 12: DATA AND DATABASE ADMINISTRATION Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman,
TM 13-1 Copyright © 1999 Addison Wesley Longman, Inc. Data and Database Administration.
Transaction Management and Concurrency Control
Transaction Properties
Database Processing: David M. Kroenke’s Chapter Nine: Part One
Chapter 10 Transaction Management and Concurrency Control
Chapter 10 Transaction Management and Concurrency Control
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Transaction management
Presentation transcript:

Transaction Processing Concepts Recovery & Concurrency Control Transaction Processing Concepts

What is a Transaction? A transaction is a logical unit of work that must be either entirely completed or aborted. A database request is the equivalent of a single SQL statement in an application program or transaction. A transaction that changes the contents of the database must alter the database from one consistent database state to another. To ensure consistency of the database, every transaction must begin with the database in a known consistent state.

Example of Transaction Amount in stock = X X = 100 Initial State <Consistent State> X = X - 50 Transaction A <Modifies database> X = 50 Final State <Consistent State>

Transaction ACID Properties Atomic “ALL OR NOTHING” Transaction cannot be subdivided Consistent Transaction  transform database from one consistent state to another consistent state Isolated Transactions execute independently of one another Database changes not revealed to users until after transaction has completed Durable Database changes are permanent The permanence of the database’s consistent state ACID

Transaction Management with SQL Transaction support is provided by 2 SQL statements: COMMIT ROLLBACK. When a transaction sequence is initiated, it must continue through all succeeding SQL statements until one of the following four events occurs: A COMMIT statement is reached. A ROLLBACK statement is reached. The end of a program is successfully reached (COMMIT). The program is abnormally terminated (ROLLBACK).

Transaction Management with SQL Example: UPDATE PRODUCT SET PROD_QOH = PROD_QOH - 200 WHERE PROD_CODE = ‘QS123XY’; UPDATE ACCT_RECEIVABLE SET ACCT_BALANCE = ACCT_BALANCE + 10000 WHERE ACCT_NUM = ‘12345678’; COMMIT;

Concurrency Control Problem – in a multi-user environment, simultaneous access to data can result in interference and data loss Solution: Concurrency Control The process of managing simultaneous operations against a database so that data integrity is maintained and the operations do not interfere with each other in a multi-user environment

Concurrency Control The objective of concurrency control is to ensure the serializability of transactions in a multi-user database environment. Simultaneous execution of transactions over a shared database can create several data integrity and consistency problems: Lost Updates. Uncommitted Data. Inconsistent retrievals.

Lost Updates An apparently successfully completed update operation by one user can be overridden by another user Simultaneous access causes updates to cancel each other

Lost Updates - Example Using Product Table: Product’s quantity on Hand (PROD_QOH) Two concurrent transactions update PROD_QOH: See Table 1 for the serial execution under normal circumstances. See Table 2 for the lost update problems resulting from the execution of the second transaction before the first transaction is committed. TRANSACTION COMPUTATION T1: Purchase 100 units PROD_QOH = PROD_QOH + 100 T2: Sell 30 units PROD_QOH = PROD_QOH - 30

Lost Updates - Example Table 2: Lost Updates Table 1: Normal Execution Of Two Transactions Table 2: Lost Updates

Lost Updates - Example

Inconsistent Retrieval Occurs when a transaction reads several values from the database but a second transaction updates some of them during the execution of the first. Occurs when a transaction calculates some summary (aggregate) functions over a set of data while other transactions are updating the data. Example: T1 calculates the total quantity on hand of the products stored in the PRODUCT table. At the same time, T2 updates the quantity on hand (PROD_QOH) for two of the PRODUCT table’s products.

Inconsistent Retrieval - Example Retrieval During Update

Concurrency Control Techniques Serializability Finish one transaction before starting another Serializable schedule Transactions  not interfere with each other can still run in parallel Locking Mechanisms The most common way of achieving serialization Data that is retrieved for the purpose of updating is locked for the updater No other user can perform update until unlocked

Updates with locking (concurrency control)

Locking Mechanisms Locking level / lock granularity: Database–used during database updates Table–used for bulk updates Block or page–very commonly used Record–only requested row; fairly commonly used Field–requires significant overhead; impractical

Database Lock

Table Lock

Block or Page Lock

Record Lock

Locking Mechanisms Types of locks: Shared lock (S locks/read locks) Allows other transactions to read but not update a record or other resources Read but no update permitted. Used when just reading to prevent another user from placing an exclusive lock on the record Exclusive lock (X locks/write locks) Prevents another transactions from reading and therefore updating a record until it is unlocked. No access permitted. Used when preparing to update

Locking: Preventing Lost Update

Locking: Preventing Uncommitted Data

Deadlock The problem of deadlock An impasse that may results when two or more transactions have locked common resources, and each waits for the other to unlock their resources The problem of deadlock John and Marsha will wait forever for each other to release their locked resources!

T1: access data items X and Y T2: access data items Y and X

Managing Deadlock Deadlock prevention: Lock all records required at the beginning of a transaction Two-phase locking protocol Growing phase Shrinking phase May be difficult to determine all needed resources in advance

Deadlock prevention Two-phase locking protocol Growing phase A transaction acquires all the required locks without unlocking any data Once all locks have been acquired, the transaction is in its locked point Shrinking phase A transaction releases all locks and cannot obtain any new lock

Two-phase locking protocol

Managing Deadlock Deadlock Resolution: Allow deadlocks to occur but build mechanisms into the DBMS for detecting and breaking the deadlocks. The DBMS maintains a matrix of resource usage. Indicates what subjects (users) are using what objects (resources) Scanning this matrix: the computer can detect deadlock if occur DBMS resolve deadlock: One of the transactions is aborted: changes made by the transaction up to the time of deadlock are removed & transaction is restarted when the required resources become available.

Versioning Optimistic approach to concurrency control Instead of locking Assumption is that simultaneous updates will be infrequent Each transaction can attempt an update as it wishes The system will reject an update when it senses a conflict Use of rollback and commit for this

The use of versioning Better performance than locking

Data Dictionaries and Repositories Data dictionary Documents data elements of a database Store metadata/information about the database Active: managed by DBMS Passive: managed by the user(s) Part of system catalog System catalog System-created database that describes all database objects Table-related data (table names), table creators/owners, column names, data types, etc

Data Dictionaries and Repositories Information Repository Stores metadata that describe an organization’s data and data processing resources, manages the total information processing environment and combines information about an organization's business information and its application portfolio Information Repository Dictionary System (IRDS) Software tool that is used to manage and control access to the information repository 3 components of repository system architecture: Information Model Repository Engine Repository Database

Three components of the repository system architecture A schema of the repository information Software that manages the repository objects Where repository objects are stored Source: adapted from Bernstein, 1996.

Data Availability Downtime is expensive How to ensure availability Lost business during the outage Cost of catching up when service is restored Legal costs Permanent loss of customer loyalty How to ensure availability Hardware failures–provide standby components Loss of data–database mirroring Human Error – SOP, training, documentation Maintenance downtime–automated and non-disruptive maintenance utilities Network problems–careful traffic monitoring, firewalls, and routers

END OF CHAPTER Information in this slides were taken from: Modern Database Management System, Ninth edition by Jeffrey A.Hoffer, Mary B.Prescott & Heikki Topi. Database Systems, Design, Implementation & Management by Peter Rob & Carlos Coronel Database Systems: A Practical Approach to Design, Implementation and Management by Thomas Connolly & Carolyn Begg