Docsity

Transaction Processing Concepts and Theory - Lecture Notes | CS 6400, Study notes of Computer Science

Partial preview of the text

Download Transaction Processing Concepts and Theory - Lecture Notes | CS 6400 and more Study notes Computer Science in PDF only on Docsity!

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe

Chapter 17

Introduction to Transaction

Processing Concepts and Theory

1 Introduction to Transaction

Processing (1)

n Single-User System :

n At most one user at a time can use the system.

n Multiuser System :

n Many users can access the system concurrently.

n Concurrency

n Interleaved processing :

n Concurrent execution of processes is interleaved in a single CPU

n Parallel processing :

n Processes are concurrently executed in multiple CPUs.

Introduction to Transaction Processing (2)

n A Transaction :

n Logical unit of database processing that includes one or more access operations (read -retrieval, write - insert or update, delete).

n 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.

n Transaction boundaries :

n Begin and End transaction.

n An application program may contain several transactions separated by the Begin and End transaction boundaries.

Introduction to Transaction Processing (4)

READ AND WRITE OPERATIONS:

n 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, although it may be a larger unit such as a record or even a whole block.

n read_item(X) command includes the following steps:

n Find the address of the disk block that contains item X. n Copy that disk block into a buffer in main memory (if that disk block is not already in some main memory buffer). n Copy item X from the buffer to the program variable named X.

Introduction to Transaction Processing (5)

READ AND WRITE OPERATIONS (contd.):

n write_item(X ) command includes the following steps:

n Find the address of the disk block that contains item X. n Copy that disk block into a buffer in main memory (if that disk block is not already in some main memory buffer). n Copy item X from the program variable named X into its correct location in the buffer. n Store the updated block from the buffer back to disk (either immediately or at some later point in time).

Introduction to Transaction Processing (6)

Why Concurrency Control is needed: n The Lost Update Problem n 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. n The Temporary Update (or Dirty Read) Problem n This occurs when one transaction updates a database item and then the transaction fails for some reason (see Section 17.1.4). n The updated item is accessed by another transaction before it is changed back to its original value. n The Incorrect Summary Problem n 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.

Concurrent execution is uncontrolled:

(a) The lost update problem.

Concurrent execution is uncontrolled:

(c) The incorrect summary problem.

Introduction to Transaction

Processing (12)

Why recovery is needed:

(What causes a Transaction to fail)

  1. A computer failure (system crash): A hardware or 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.

Introduction to Transaction

Processing (14)

Why recovery is needed (contd.):

(What causes a Transaction to fail)

  1. 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.
  2. 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 (1)

n A transaction is an atomic unit of work that is

either completed in its entirety or not done at all.

n For recovery purposes, the system needs to

keep track of when the transaction starts,

terminates, and commits or aborts.

n Transaction states :

n Active state

n Partially committed state

n Committed state

n Failed state

n Terminated State

Transaction and System Concepts (3)

n Recovery manager keeps track of the following

operations (cont):

n 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.

n 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.

Transaction and System Concepts (4)

n Recovery techniques use the following operators:

n undo : Similar to rollback except that it applies to a

single operation rather than to a whole transaction.

n 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.