160 likes | 449 Views
Concurrency Control. Overview of Database 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
E N D
Concurrency Control Overview of Database Concurrency Control 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. 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). 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 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. 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. 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. 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). 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. 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 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 BACS 485—Database Management Concurrency Control
Lost Update Problem BACS 485—Database Management Concurrency Control
Temporary Update Problem BACS 485—Database Management Concurrency Control
Incorrect Summary Problem BACS 485—Database Management Concurrency Control
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
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