Presentation is loading. Please wait.

Presentation is loading. Please wait.

BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control.

Similar presentations


Presentation on theme: "BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control."— Presentation transcript:

1 BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control

2 BACS 485—Database Management Concurrency Control Lecture Objectives Learn the basic concepts associated with concurrency control in a relational database environment. Learn about serial and serializable schedules. Learn the basic concurrency control protocols Learn the basics of locks and timestamps as there are used in concurrency control.

3 BACS 485—Database Management Concurrency Control Concurrency Background Modern databases gain their usefulness by sharing data among many users. The cost of sharing data is concurrency problems. Modern DBMSs deal with concurrency problems by controlling the interaction among users to maintain database consistency (integrity).

4 BACS 485—Database Management Concurrency Control Concurrency Background There are 5 basic background concepts related to concurrency control: Multiprogramming Data Sharing Concurrent access vs. integrity conflict Transactions Levels of concurrency control

5 BACS 485—Database Management Concurrency Control Multiprogramming Multiprogramming is the process of interleaving (shuffling) the operations of several programs in order to better utilize the system resources. By quickly switching “contexts”, the illusion of simultaneous execution is possible on a single CPU computer.

6 BACS 485—Database Management Concurrency Control Data Sharing Database systems share data to reduce redundancy and gain better control through centralization. Shared data that is dynamic (i.e., update, insert, delete) causes concurrency problems in database environments. Strictly “read only” shared data does not cause concurrency problems.

7 BACS 485—Database Management Concurrency Control Concurrency vs. Integrity There is a conflict between total concurrent data access and database integrity. The more concurrency that takes place, the potentially worse the integrity. Conversely, the better the integrity, the less concurrency is possible. The goal is to achieve a reasonable balance.

8 BACS 485—Database Management Concurrency Control Transactions Transactions are a logical unit of work in the database. By executing transactions, the database moves from one consistent state to another. Transactions are important is several areas of database theory (including concurrency).

9 BACS 485—Database Management Concurrency Control Transactions Good transactions have the following characteristics: Atomic – performed totally or not at all Consistency preservation – consistent state is maintained before and after the transaction is executed. Permanence – Changes that are “committed” are permanent. They cannot be lost. Isolation – Transaction updates should not be visible outside of the transaction. Serializability – Running interleaved transactions should produce the same result as running them in some serial order.

10 BACS 485—Database Management Concurrency Control Levels of Control The concurrency mechanisms that will be discussed in this slide set apply to multiple levels of the database. Specifically, they can apply to: Data-item level Tuple level Table level Extent level Full database

11 BACS 485—Database Management Concurrency Control Uncontrolled Concurrency Uncontrolled concurrency implies that the transactions are interleaved randomly. This causes 3 classic problems: Lost update problem Temporary update problem Incorrect summary problem

12 BACS 485—Database Management Concurrency Control Lost Update Problem

13 BACS 485—Database Management Concurrency Control Temporary Update Problem

14 BACS 485—Database Management Concurrency Control Incorrect Summary Problem

15 How do you avoid these problems? You can avoid the problems of uncontrolled concurrency by generating “serializable schedules.” A “schedule” is a plan for transaction execution. A “serial schedule” is one where there is no concurrency (one transaction after another). A serializable schedule is one that allows instruction interleaving while still giving serial schedule results. BACS 486—Advanced Database Management Concurrency Control

16 Schedules assume… Transactions are individually correct If database consistent (i.e., correct) before a transaction, it will be consistent after Schedules preserve instruction order A serial execution of several transactions is “correct” by definition Interleaved execution is “correct” it is equivalent to any serial execution (called a “serializable schedule”) BACS 486—Advanced Database Management Concurrency Control

17 Schedule Example Example: T1 transfers $50 from checking to savings while T2 takes 10% of checking and puts it into savings. Initial value checking $1000, savings $2000. T1T2READ checking-balance Balance = Balance - 50Temp = Balance * 10% WRITE checking-balanceBalance = Balance - Temp READ savings-balanceWRITE checking-balance Balance = Balance + 50READ savings-balance WRITE savings-balanceBalance = Balance + Temp WRITE savings-balance BACS 486—Advanced Database Management Concurrency Control

18 Schedule Example SCHEDULE 1: T1| T2 ________________________|____________________________ READ checking-balance| Balance = Balance - 50| WRITE checking-balance| READ savings-balance| Balance = Balance + 50| WRITE savings-balance| | READ checking-balance | Temp = Balance * 10% | Balance = Balance - Temp | WRITE checking-balance | READ savings-balance | Balance = Balance + Temp | WRITE savings-balance Checking Value = $855 Savings Value = $2145 BACS 486—Advanced Database Management Concurrency Control

19 Schedule Example SCHEDULE 2: T1| T2 ________________________|____________________________ | READ checking-balance | Temp = Balance * 10% | Balance = Balance - Temp | WRITE checking-balance | READ savings-balance | Balance = Balance + Temp | WRITE savings-balance READ checking-balance | Balance = Balance - 50| WRITE checking-balance| READ savings-balance| Balance = Balance + 50| WRITE savings-balance| Checking Value = $850 Savings Value = $2150 BACS 486—Advanced Database Management Concurrency Control

20 Locks and Protocols Types of simple Locks Exclusive Locks Shared Locks (read locks) Update Locks Lock Problems Deadlock Livelock BACS 486—Advanced Database Management Concurrency Control


Download ppt "BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control."

Similar presentations


Ads by Google