1 IRU Concurrency, Reliability and Integrity issues Geoff Leese October 2007 updated August 2008, October 2009.

Slides:



Advertisements
Similar presentations
Data recovery 1. 2 Recovery - introduction recovery restoring a system, after an error or failure, to a state that was previously known as correct have.
Advertisements

Concurrency Control Alexandra Cristea and Steve Russ 1.
Crash Recovery John Ortiz. Lecture 22Crash Recovery2 Review: The ACID properties  Atomicity: All actions in the transaction happen, or none happens 
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Recovery CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
CSCI 3140 Module 8 – Database Recovery Theodore Chiasson Dalhousie University.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
More on transactions…. Dealing with concurrency (OR: how to handle the pressure!) Locking Timestamp ordering Multiversion protocols Optimistic protocols.
Recovery 10/18/05. Implementing atomicity Note, when a transaction commits, the portion of the system implementing durability ensures the transaction’s.
Database Administration Chapter Six DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Transaction Management and Concurrency Control
1 Minggu 8, Pertemuan 16 Transaction Management (cont.) Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
10 1 Chapter 10 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
What is a Transaction? Logical unit of work
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
1 Transaction Management Database recovery Concurrency control.
DBMS Functions Data, Storage, Retrieval, and Update
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Functions of a Database Management System. Functions of a DBMS C.J. Date n Indexing n Views n Security n Integrity n Concurrency n Backup/Recovery n Design.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Transaction Management and Concurrency Control
Transactions and Recovery
Academic Year 2014 Spring. MODULE CC3005NI: Advanced Database Systems “DATABASE RECOVERY” (PART – 1) Academic Year 2014 Spring.
DBSQL 7-1 Copyright © Genetic Computer School 2009 Chapter 7 Transaction Management, Database Security and Recovery.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
Concepts of Database Management, Fifth Edition
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Reliability and Security in Database Servers By Samuel Njoroge.
Chapterb19 Transaction Management Transaction: An action, or series of actions, carried out by a single user or application program, which reads or updates.
Transaction Processing Concepts. 1. Introduction To transaction Processing 1.1 Single User VS Multi User Systems One criteria to classify Database is.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Copyright © Curt Hill Database Function What should every database do?
Ch 10: Transaction Management and Concurrent Control.
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
Chapter 15 Recovery. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.15-2 Topics in this Chapter Transactions Transaction Recovery System.
Transactions and Locks A Quick Reference and Summary BIT 275.
INFO1408 Database Design Concepts Week 16: Introduction to Database Management Systems Continued.
© 2002 by Prentice Hall 1 Database Administration David M. Kroenke Database Concepts 1e Chapter 6 6.
The Relational Model1 Transaction Processing Units of Work.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
Concurrency Control Dr. Tariq Ahamad 1. Who needs ‘control’? large databases are usually shared – by many users, and resources it is efficient to allow.
Section 06 (a)RDBMS (a) Supplement RDBMS Issues 2 HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
DATABASE CONTROLS Chapter 14. Access Controls Discretionary Access Controls Discretionary Access Controls Types of Restrictions : 1. Name-dependent restrictions.
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
Motivation for Recovery Atomicity: –Transactions may abort (“Rollback”). Durability: –What if DBMS stops running? (Causes?) crash! v Desired Behavior after.
18 September 2008CIS 340 # 1 Last Covered (almost)(almost) Variety of middleware mechanisms Gain? Enable n-tier architectures while not necessarily using.
1 Information Retrieval and Use De-normalisation and Distributed database systems Geoff Leese September 2008, revised October 2009.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
9 1 Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Transaction Management
Transaction Properties
Chapter 10 Transaction Management and Concurrency Control
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Database Administration
Presentation transcript:

1 IRU Concurrency, Reliability and Integrity issues Geoff Leese October 2007 updated August 2008, October 2009

2 Introduction n The concept of a transaction n Handling concurrent access n Database reliability n Ensuring integrity

3 A transaction n Unit of database work n Support concurrency control and crash recovery n Atomic ä All actions carried out, or none n Consistent ä Data always left in a consistent state n Isolated ä Database handles concurrency issues n Durable ä Completed transactions persist even if database not updated

4 Concurrency control n How do we handle ä Lost operations? ä Inconsistent data retrieval?

5 Lost operations example n Two transactions operating concurrently ä Update stock, product abc123, adding 20 ä Update stock, product abc123, adding 50 n Current stock level of product abc123 is 100

6 Lost operations example ADD 50 TO STOCK LEVEL TIME TRANSACTION 1TRANSACTION 2 READ IN RECORD FOR ABC123 READ IN RECORD FOR ABC123 ADD 20 TO STOCK LEVEL WRITE RECORD BACK BECAUSE OF THE TIMINGS, TRANSACTION 2 IS LOST!

7 Inconsistent data retrieval example n Two transactions, operating concurrently ä Give me details of product abc123, then a summary of the group of products containing product abc123 ä Update stock, product abc123, adding 50

8 Inconsistent data retrieval example TIME TRANSACTION 1TRANSACTION 2 READ IN RECORD FOR ABC123 READ IN RECORD FOR ABC123 SHOW PRODUCT DETAILS SHOW GROUP SUMMARY WRITE RECORD BACK ADD 50 TO STOCK BECAUSE OF TIMINGS, GROUP SUMMARY DOESN’T MATCH DETAILS FOR ABC123!

9 INCONSISTENT DATA RETRIEVAL EXAMPLE TIME TRANSACTION 1TRANSACTION 2 READ IN RECORD FOR ABC123 READ IN RECORD FOR ABC123 SHOW PRODUCT DETAILS SHOW GROUP SUMMARY ADD 50 TO STOCK TRANSACTION 1 IS NOW SELF-CONSISTENT, BUT DETAILS ARE BASED ON AN ABORTED TRANSACTION! ROLLBACK

10 Serialisable transactions n Allow transactions to run concurrently, but have the effect of executing one at a time n If read access required, stop concurrent changes n If write/modify access required, stop all concurrent access

11 Shared/exclusive locking n Shared locking - allows other transactions to read data, but transactions requiring to update have to wait n Exclusive locking - applied during updates, all other transactions must wait

12 Rules for locking n Shared locks applied as soon as exclusive locks removed n Exclusive locks applied as soon as all other locks removed n Locks removed following commit/rollback n Locks applied at record or page level

13 TIME TRANSACTION 1TRANSACTION 2 APPLY EXCLUSIVE LOCK TO X APPLY EXCLUSIVE LOCK TO Y REQUEST EXCLUSIVE LOCK ON Y REQUEST EXCLUSIVE LOCK ON X BOTH TRANSACTIONS ARE DEADLOCKED! DEADLOCK EXAMPLE Two transactions, both update data object x and data object y

14 Pessimistic locking n All possible data objects required by a transaction are locked when transaction begins n Therefore avoids deadlock n Data locked for full duration of transaction, whether required or not!

15 Optimistic locking n Allows deadlocks to occur n Identifies them and aborts victim transactions n Significant performance delay due to repeated deadlock/rollback/restart cycle

16 Reliability (DBMS facilities) n Commit ä Make permanent changes n Rollback ä Return to previous values n Transaction logging ä Checkpoints) n BIJ – before image journal n AIJ – after image journal

17 Disaster recovery (1) n System crash/media failure n Transaction log is assumed to survive the crash (mirror it elsewhere?) n Restore backup copies ä They were kept offsite??)

18 Disaster recovery(2) n Recovery manager ä ANALYSE uncommitted and active transactions ä REDO uncommitted transactions ä UNDO incomplete transaction ä REPORT what has been done n UPDATE transaction log during recovery n Use checkpoints to reduce workload should system crash again before recovery complete

19 Physical reliability measures n Network redundancy ä Covered in other modules n Distributed database technology ä Ensures some survivability n Regular backups kept offsite ä Including backups of transaction files n Mirror sites for maximum survivability ä Only worthwhile for mission critical systems ä Update propagation is obviously an issue

20 Integrity n Ensuring “correctness”? n Only really ensuring consistency – “correctness” is a user concept connected with meaning!

21 Constraints n Type constraints ä Built-in ä User defined n Attribute constraints n Entity constraints ä Involves only one entity n Database constraint ä Involves two or more entities

22 Type constraints n Built in types ä CHAR, NUMBER, DATE etc n User defined types ä Constructed from built-in types n Choose or construct an appropriate type for all attributes!

23 Attribute constraints n At least partially met by use of TYPE constraints. n Consider also ä Maximum and minimum values ä Uniqueness? Nulls allowed? n ORACLE attribute constraints (exist as objects) ä CHECK ä UNIQUE ä NOT NULL

24 Entity constraints n Primary key ä ORACLE primary key constraint n Alternate key(s) n Transition constraints ä Student can become a binned student, but not the reverse……. (not here anyway!)

25 Database constraints n Foreign key ä ORACLE Foreign key constraint) n Referential integrity ä DELETE actions –Restrict (default) –Set null –Cascade ä UPDATE action –Cascade Use “ON DELETE” clause when specifying FK constraint Use “REFERENCES” clause when specifying FK constraint

26 Summary n The concept of a transaction n Handling concurrent access n Database reliability n Ensuring integrity

27 Further reading n Rolland chapter 9 n Date chapters 9, 15 and 16 n Patrick chapters 6, 8 and 19 n A bloggers view of database integrity – click to follow the link A bloggers view of database integrity – click to follow the link