CP363 : Transactions

Database Concurrency is defined by the number of users who may access the database simultaneously:

Transactions

A database transaction is a logical unit of database processing. It consists of a series of database access operations: insertion, deletions, selection, updating.

A transaction can be part of a user program or an interactive session.

Transactions can be read-only (selection) or updates (insertion, deletion, update).

Transactions have a clearly defined beginning and end. Example: an ATM transaction. There is an explicit login followed by a series of other transactions (deposit, withdrawl, transfer, balance) followed by an implicit logout. Each transaction must be finished before moving onto the next one.

At the physics level transactions involve a series of reads and writes to and from memory and disk. (We will worry about the physical layer in only a few special cases).

ACID properties. Transactions are:

Concurrency Problems

Transaction States

System Log

Types of Failures

System Failures

Media Failures

Log may recover from:

Logs are scanned from tail to head to create a list of committed transactions, and then from head to tail to commit those transactions.

Checkpoints reduce the amount of log data that must be scanned after a failure. Tail to head scan goes only until last checkpoint (after system failure).

Checkpoint algorithm:

  1. prevent new transactions from starting, and wait for active transactions to finish
  2. copy memory buffers to disk
  3. write a checkpoint record in the log
  4. allow new transactions to start

Concurrency

For performance reasons, a database processing several transactions simultaneously. However, transactions appear to be processed serially.

Database Concurrency is defined by the number of users who may access the database simultaneously: