Transaction Management - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Transaction Management

Description:

Device characteristics and failure types. Recovery tools. Recovery processes. Storage Device Basics. Volatile: loses state after a shutdown ... – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 42
Provided by: michae1242
Category:

less

Transcript and Presenter's Notes

Title: Transaction Management


1
Chapter 13
  • Transaction Management

2
Outline
  • Transaction basics
  • Concurrency control
  • Recovery management
  • Transaction design issues
  • Workflow management

3
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

4
Airline Transaction Example
BEGIN 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
5
Transaction Properties
  • Atomic all or nothing
  • Consistent database must be consistent before
    and after a transaction
  • Isolated no interference from multiple users
  • Durable database changes are permanent after the
    transaction completes

6
Transaction Processing Services
  • Concurrency control
  • Recovery management
  • Service characteristics
  • Transparent
  • Consume significant resources
  • Significant cost component

7
Concurrency Control
  • Problem definition
  • Concurrency control problems
  • Concurrency control tools

8
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

9
Lost Update Problem
10
Uncommitted Dependency Problem
11
Incorrect Summary Problem
12
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

13
Locking Granularity
14
Deadlock (Mutual Waiting)
15
Deadlock Resolution
  • Detection
  • Can involve significant overhead
  • Not widely used
  • Prevention
  • Use timeout
  • Can abort transactions that are not deadlocked
  • Widely used although timeout interval is
    difficult to determine

16
Two Phase Locking (2PL)
  • Protocol to prevent lost update problems
  • All transactions must follow
  • Conditions
  • Obtain lock before accessing item
  • Cannot obtain new locks after releasing locks

17
2PL Implementation
18
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

19
Recovery Management
  • Device characteristics and failure types
  • Recovery tools
  • Recovery processes

20
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

21
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

22
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

23
Transaction Log Example
24
Other Recovery Tools
  • Checkpointing reduces restart work but adds
    overhead
  • Checkpoint table current log position
  • Checkpoint log record active transactions
  • Checkpoint interval time between checkpoints
  • Force writing
  • Database backup

25
Recovery from a Media Failure
  • Restore database from the most recent backup
  • Redo all committed transactions since the most
    recent backup
  • Restart active transactions

26
Recovery Timeline
27
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

28
Immediate Update Recovery
29
Deferred Update Recovery
30
Transaction Design Issues
  • Transaction boundary
  • Isolation levels
  • Deferred constraint checking

31
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

32
Registration Form Example
33
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

34
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 incorrect summary problems
  • Specify using the SET TRANSACTION statement

35
Common Isolation Levels
  • Serializable no interference problems
  • Read stability prevents lost update, uncommitted
    dependency, and some incorrect summary problems
  • Cursor stability prevents lost update and
    uncommitted dependency problems
  • Uncommitted read prevents only lost update
    problems

36
Integrity Constraint Timing
  • Most constraints checked immediately
  • Can defer constraint checking to EOT
  • SQL SET CONSTRAINTS statement

37
Workflow Management
  • Workflow description
  • Enabling technologies
  • Advanced transaction management

38
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

39
Enabling Technologies
  • Distributed object management
  • Many kinds of nontraditional data
  • Data often dispersed in location
  • Workflow modeling
  • Specification
  • Simulation
  • Optimization

40
Advanced Transaction Management
  • Conversational transactions
  • Transactions with complex structure
  • Transactions involving legacy systems
  • Compensating transactions
  • More flexible transaction processing

41
Summary
  • Transaction user-defined collection of work
  • DBMS 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
Write a Comment
User Comments (0)
About PowerShow.com