Ch 21: Transaction Processing

Slides:



Advertisements
Similar presentations
What is Concurrent Process (CP)? Multiple users access databases and use computer systems Multiple users access databases and use computer systems simultaneously.
Advertisements

IDA / ADIT Lecture 10: Database recovery Jose M. Peña
Database Recovery Unit 12 Database Recovery 12-1.
Transactions (Chapter ). What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions.
Chapter 17 Introduction to Transaction Processing Concepts and Theory Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 17 Introduction to Transaction Processing Concepts and Theory.
Recovery CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
ACS R McFadyen 1 Transaction A transaction is an atomic unit of work that is either completed in its entirety or not done at all. For recovery purposes,
ACS-4902 R McFadyen 1 Chapter 17 Introduction to Transaction Processing Concepts and Theory 17.1, 17.2, 17.3, 17.5, 17.6.
Transaction Processing: September 27, Database Access For TP, represent database as a collection of named items. Read(X) - read database item X.
Concurrency control using transactions 1Transactions.
ICS (072)Transaction Processing Concepts and Theory 1 Introduction to Transaction Processing Concepts and Theory Chapter 17 Dr. Muhammad Shafique.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
1 Introduction to Transaction Processing (1)
1 BASIC TRANSACTION CONCEPTS A Transaction: logical unit of database processing that includes one or more access operations (read -retrieval, write – insert.
1 Introduction to Transaction Processing Concepts and Theory.
Database Systems Chapter 17 ITM 354 Dr. Rick Kazman.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 21 Introduction to Transaction Processing Concepts and Theory.
Transaction Processing
System Catalogue v Stores data that describes each database v meta-data: – conceptual, logical, physical schema – mapping between schemata – info for query.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Academic Year 2014 Spring. MODULE CC3005NI: Advanced Database Systems “DATABASE RECOVERY” (PART – 1) Academic Year 2014 Spring.
INTRODUCTION TO TRANSACTION PROCESSING CHAPTER 21 (6/E) CHAPTER 17 (5/E)
Advanced Database Technologies Lecture 6: Transactions and Database Recovery.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 21 Introduction to Transaction Processing Concepts and Theory.
Chapter 17 Introduction to Transaction Processing Concepts and Theory Copyright © 2004 Pearson Education, Inc.
1 CSE 480: Database Systems Lecture 23: Transaction Processing and Database Recovery.
Transaction Processing Concepts
1 Database Systems CS204 Lecture 21 Transaction Processing I Asma Ahmad FAST-NU April 7, 2011.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Introduction to Transaction.
The Concept of Transaction Processing A Transaction: logical unit of database processing that includes one or more access operations (read - retrieval,
Transaction Processing Concepts. 1. Introduction To transaction Processing 1.1 Single User VS Multi User Systems One criteria to classify Database is.
Quick revision on Transaction Processing Concepts By: Dr. Yousry Taha Copyright 2010.
1 Transactions Transaction: –A unit of work –A sequence of operations which are bundled together Either all of them should be executed or none i.e. not.
1 Chapter 4 Introduction to Transaction Processing Concepts and Theory Adapted from the slides of “Fundamentals of Database Systems” (Elmasri et al., 2003)
Chapter 17 Introduction to Transaction Processing Concepts and Theory Copyright © 2004 Pearson Education, Inc.
CSCI Transaction Processing Concepts 1 TRANSACTION PROCESSING CONCEPTS Dr. Awad Khalil Computer Science Department AUC.
CSCI Recovery Control Techniques 1 RECOVERY CONTROL TECHNIQUES Dr. Awad Khalil Computer Science Department AUC.
Database Systems Recovery & Concurrency Lecture # 20 1 st April, 2011.
Transaction Processing The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe, Fundamental of Database Systems, 4th 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.
Transactions.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Transaction Processing Concepts Muheet Ahmed Butt.
CSE314 Database Systems Introduction To Transaction Processing Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Lec 8 Introduction to Transaction Processing Concepts and Theory Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Lecture 5 Introduction to Transaction Processing Concepts and Theory.

Database Recovery Techniques
Database System Implementation CSE 507
Database System Implementation CSE 507
Database Management System
1 Introduction to Transaction Processing (1)
Backup and Recovery Techniques
Chap 20 – Transaction Processing
Introduction to Transaction Processing Concepts and Theory
Introduction to Transaction Processing Concepts and Theory
Introduction to Transaction Processing Concepts and Theory
Chapter 10 Transaction Management and Concurrency Control
12/4/2018.
1 Introduction to Transaction Processing (1)
Recovery System.
2/23/2019.
Transaction management
Introduction to Transaction Processing Concepts and Theory
Backup and Recovery Techniques
Lec 9: Introduction to Transaction Processing Concepts and Theory
UNIT -IV Transaction.
Presentation transcript:

Ch 21: Transaction Processing Transaction Definitions Transaction and System Concepts Desirable Properties of Transactions Characterizing Schedules based on Recoverability Characterizing Schedules based on Serializability Transaction Support in SQL

Transaction Processing (1) Single-User System: At most one user at a time can use the system. Multiuser System: Many users can access the system concurrently. Concurrency Interleaved processing: Concurrent execution of processes is interleaved in a single CPU Parallel processing: Processes are concurrently executed in multiple CPUs. Ex: Airline reservation sys, db sys in banks, stock markets, supermarkets, insurance companies...

Transaction Processing:Definition A Transaction: Logical unit of database processing that includes one or more access operations (read -retrieval, write - insert or update, delete). A transaction (set of operations) may be stand-alone specified in a high level language like SQL submitted interactively, or may be embedded within a program. Transaction boundaries: Begin and End transaction. An application program may contain several transactions separated by the Begin and End transaction boundaries. Read-only transaction (only retrieve ops, no update) vs. read-write transaction

Transaction Processing: Model SIMPLE MODEL OF A DATABASE (for purposes of discussing transactions): A database is a collection of named data items Granularity of data - a field, a record , or a whole disk block (Concepts are independent of granularity) Basic operations are read and write read_item(X): Reads a database item named X into a program variable. To simplify our notation, we assume that the program variable is also named X. write_item(X): Writes the value of program variable X into the database item named X.

Transaction Processing:read & write ops Basic unit of data transfer from the disk to the computer main memory is one block. In general, a data item (what is read or written) will be the field of some record in the database. But it may be a larger unit such as a record or even a whole block. read_item(X) command includes the following steps: Find the address of the disk block that contains item X. Copy that disk block into a buffer in main memory (if that disk block is not already in some main memory buffer). Copy item X from the buffer to the program variable named X. write_item(X) command includes the following steps: Copy item X from the program variable named X into its correct location in the buffer. Store the updated block from the buffer back to disk (either immediately or at some later point in time).

Two Sample Transactions: contains read-ıtem, write-item read-set=write-set={X, Y}

Concurrency Control and Recovery Concerned with db commands in a transaction Many transactions may execute concurrently, access and update the same db items. If uncontrolled, result in some problems (ie, inconsistent database) Ex: a record for each airline flight includes #of reserved seats T1: transfers N reservations from one flight (item X) to another flight (item Y) T2: just reserves M seats on the first flight (item X) Ignore portions of transactions such as check for seat availability Parameters in DB program: flight number, date, number of seats (to book)

Transaction Processing:Why need Concurrency Control The Lost Update Problem This occurs when two transactions that access the same database items have their operations interleaved in a way that makes the value of some database item incorrect. Final value of X is incorrect since T2 reads X before T1 changes it in the db. (X=80, N=5, M=4 -> X=84 (79)) The Temporary Update (or Dirty Read) Problem This occurs when one transaction updates a database item and then the transaction fails for some reason. The updated item is accessed by another transaction before it is changed back to its original value. T1 updates X and fails. Change X to original. But before that T2 reads temp value of X (which is not permenant in db) The Incorrect Summary Problem If one transaction is calculating an aggregate summary function on a number of records while other transactions are updating some of these records, the aggregate function may calculate some values before they are updated and others after they are updated. T3: total number of reservations on all flights while T1 is executing. T3 is off by N since T3 reads X after N seats are subtracted but reads Y before N seats added to Y

Concurrent execution is uncontrolled: (a) The lost update problem.

Concurrent execution is uncontrolled: (b) The temporary update problem.

Concurrent execution is uncontrolled: (c) The incorrect summary problem.

Transaction Processing: recovery When a trans is submitted to a DBMS, either all operations in it are completed successfully and their effect is recorded permenantly in db (committed) or trans has no effect in the db or any other transactions (trans is aborted). Transaction cannot be partially applied to the db. T fails after some ops applied, then these ops must be undone and have no lasting effect. Why recovery is needed (What causes a Transaction to fail) 1. A computer failure (system crash): A hardware/software error occurs in the computer system during transaction execution. If the hardware crashes, the contents of the computer’s internal memory may be lost. 2. A transaction or system error: Some operation in the transaction may cause it to fail, such as integer overflow or division by zero. Transaction failure may also occur because of erroneous parameter values or because of a logical programming error. In addition, the user may interrupt the transaction during its execution.

Transaction Processing: recovery 3. Local errors or exception conditions detected by the transaction: Certain conditions necessitate cancellation of the transaction. For example, data for the transaction may not be found. A condition, such as insufficient account balance in a banking database, may cause a transaction, such as a fund withdrawal from that account, to be canceled. A programmed abort in the transaction causes it to fail. 4. Concurrency control enforcement: The concurrency control method may decide to abort the transaction, to be restarted later, because it violates serializability or because several transactions are in a state of deadlock 5. Disk failure: Some disk blocks may lose their data because of a read or write malfunction or because of a disk read/write head crash. This may happen during a read or a write operation of the transaction. 6. Physical problems and catastrophes: This refers to an endless list of problems that includes power or air-conditioning failure, fire, theft, sabotage, overwriting disks or tapes by mistake, and mounting of a wrong tape by the operator.

2 Transaction and System Concepts A transaction is an atomic unit of work that is either completed in its entirety or not done at all. For recovery purposes, the system needs to keep track of when the transaction starts, terminates, and commits or aborts. Transaction states: Active state Partially committed state Committed state Failed state Terminated State

Transaction and System Concepts: ops Recovery manager keeps track of the following operations: begin_transaction: This marks the beginning of transaction execution. read or write: These specify read or write operations on the database items that are executed as part of a transaction. end_transaction: This specifies that read and write transaction operations have ended and marks the end limit of transaction execution. At this point it may be necessary to check whether the changes introduced by the transaction can be permanently applied to the database or whether the transaction has to be aborted because it violates concurrency control or for some other reason.

Transaction and System Concepts:ops commit_transaction: This signals a successful end of the transaction so that any changes (updates) executed by the transaction can be safely committed to the database and will not be undone. rollback (or abort): This signals that the transaction has ended unsuccessfully, so that any changes or effects that the transaction may have applied to the database must be undone.

State Transition Diagram Illustrating the States for Transaction Execution

Transaction and System Concepts: recovery ops Recovery techniques use the following operators: undo: Similar to rollback except that it applies to a single operation rather than to a whole transaction. redo: This specifies that certain transaction operations must be redone to ensure that all the operations of a committed transaction have been applied successfully to the database.