Managing Multi-User Databases (1) IS 240 – Database Management Lecture #18 – 2004-04-20 Prof. M. E. Kabay, PhD, CISSP Norwich University

Slides:



Advertisements
Similar presentations
1 Senn, Information Technology, 3 rd Edition © 2004 Pearson Prentice Hall James A. Senns Information Technology, 3 rd Edition Chapter 7 Enterprise Databases.
Advertisements

The Relational Model and Normalization (3) IS 240 – Database Management Lecture # Prof. M. E. Kabay, PhD, CISSP Norwich University
The Relational Model and Normalization (1)
Foundations of Relational Implementation (2) IS 240 – Database Management Lecture #14 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Introduction to Database Processing IS 240 – Database Management Lecture #1 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Database Design (1) IS 240 – Database Management Lecture #10 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Foundations of Relational Implementation (1) IS 240 – Database Management Lecture #13 – Prof. M. E. Kabay, PhD, CISSP Norwich University
1 Copyright © 2004 M. E. Kabay. All rights reserved. Database Design (2) IS 240 – Database Management Lecture #11 – Prof. M. E. Kabay, PhD,
Managing Multi-User Databases (2) IS 240 – Database Management Lecture #19 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Working with MS-ACCESS IS 240 – Database Management Lecture #2 – Assoc. Prof. M. E. Kabay, PhD, CISSP Norwich University
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
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.
Concurrency control 1. 2 Introduction concurrency more than one transaction have access to data simultaneously part of transaction processing.
1 Term 2, 2004, Lecture 6, TransactionsMarian Ursu, Department of Computing, Goldsmiths College Transactions 3.
Making the System Operational
Configuration management
Lecture plan Transaction processing Concurrency control
Indra Budi Transaction Indra Budi
25 seconds left…...
Chapter 12 Managing Multi-user Databases David M. Kroenke Database Processing © 2000 Prentice Hall.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
Database Administration Chapter Six DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Transaction Management and Concurrency Control
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
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 9 Managing Multi- User.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 18.
Chapter 9 Transaction Management and Concurrency Control
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
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
TRANSACTION PROCESSING TECHNIQUES BY SON NGUYEN VIJAY RAO.
Transaction Management Chapter 9. What is a Transaction? A logical unit of work on a database A logical unit of work on a database An entire program An.
1 IT420: Database Management and Organization Transactions 31 March 2006 Adina Crăiniceanu
1 Copyright © 2014 M. E. Kabay. All rights reserved. Application Controls CSH5 Chapter 52 “Application Controls” Myles Walsh.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
Concurrency Control in Database Operating Systems.
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
© 2002 by Prentice Hall 1 Database Administration David M. Kroenke Database Concepts 1e Chapter 6 6.
The Relational Model1 Transaction Processing Units of Work.
Fundamentals, Design, and Implementation, 9/e Chapter 9 Managing Multi-User Databases.
1 IT420: Database Management and Organization Managing Multi-user Databases 29 March 2006 Adina Crăiniceanu
MBA 664 Database Management Dave Salisbury ( )
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.
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Copyright © 2016 Pearson Education, Inc. CHAPTER 12: DATA AND DATABASE ADMINISTRATION Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman,
Transaction Management and Concurrency Control
Chapter 9 Managing Multi-User Databases
Multi-User Databases Chapter 9.
Transaction Properties
Database Processing: David M. Kroenke’s Chapter Nine: Part One
Chapter 10 Transaction Management and Concurrency Control
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Presentation transcript:

Managing Multi-User Databases (1) IS 240 – Database Management Lecture #18 – Prof. M. E. Kabay, PhD, CISSP Norwich University

2 Copyright © 2004 M. E. Kabay. All rights reserved. Topics Database Administration Configuration Control Documentation Concurrency Control Atomic Transactions Resource Locking Consistent Transactions Transaction Isolation Level Cursor Type

3 Copyright © 2004 M. E. Kabay. All rights reserved. Database Administration Why might we need to administer DBs? Changing requirements Managing employee turnover Handling hardware & software failures Meeting SLAs (Service Level Agreements)

4 Copyright © 2004 M. E. Kabay. All rights reserved. Functions of the DBA Managing DB structure Controlling concurrent processing Managing processing rights & responsibilities Developing and implementing DB security Providing for DB recovery Managing DB performance & resources Maintaining the data repository

5 Copyright © 2004 M. E. Kabay. All rights reserved. Managing DB Structure Configuration Control Participate in early design and implementation Control & manage changes to structure Inevitable changes in requirements Policies on how to coordinate requests for change Procedures for testing and implementing changes Prepare for unexpected Emergency quick-response plans Participate in business-continuity planning Maintain disaster-recovery plans

6 Copyright © 2004 M. E. Kabay. All rights reserved. Documentation Documentation integral component of structure maintenance Which changes were made when Errors may not be visible for months May need to roll back changes to previous status Historical data important for trend analysis New programmers & DBAs must be able to understand system quickly

7 Copyright © 2004 M. E. Kabay. All rights reserved. Concurrency Control Atomic Transactions Resource Locking Consistent Transactions Transaction Isolation Level Cursor Type

8 Copyright © 2004 M. E. Kabay. All rights reserved. Multi-Step Transactions Are Fragile Think about order-entry system Create order-header Includes total of cost of line-items (details) Updated at END of detail data entry Begin entering line-items Enter 3 records … have not yet finished System crashes What is the value in the order-headers total field?

9 Copyright © 2004 M. E. Kabay. All rights reserved. Concurrency Causes New Problems E.g., The Lost Update Problem: User A reads inventory: finds 20 widgets. User B reads inventory: also finds 20 widgets. User A subtracts 10 widgets from 20, writes total ____ widgets back into inventory User B subtracts 5 widgets from ____, writes total ____ widgets back into inventory But actually, there are only ____ widgets left in the real inventory 20 widgets A B

10 Copyright © 2004 M. E. Kabay. All rights reserved. Atomic Transactions We want to complete All the steps of a transaction or None of the steps ATOMIC Greek a for not & tomos for cut Thus atomic means can not be cut. We mark atomic transactions with boundaries Start transaction Commit transaction If necessary, can reverse steps taken Rollback transaction ατομος

11 Copyright © 2004 M. E. Kabay. All rights reserved. Resource Locking Basic Concepts of Locking Lock Terminology Serializable Transactions Deadlocks Optimistic vs Pessimistic Locking Declaring Lock Characteristics

12 Copyright © 2004 M. E. Kabay. All rights reserved. Basic Concepts of Locking Locking is used in inter-process communication (IPC) A lock is a form of semaphore (signal) Locks allow processes to coordinate their access to resources Prevent inconsistencies In DBMS, primarily used to serialize data access One process gets control of data at a time

13 Copyright © 2004 M. E. Kabay. All rights reserved. Lock Terminology Implicit vs explicit Automatic locks placed by DBMS: implicit Programmatically ordered: explicit Lock granularity Large: database, dataset Fine: records Exclusive vs shared locks Exclusive: One process READ/WRITE No other processes allowed at all Shared: One process has R/W Other processes can only READ

14 Copyright © 2004 M. E. Kabay. All rights reserved. Conditional vs Unconditional Locking Conditional locking Process 1 locks resource A Process 2 locks resource A Receives error condition Lock fails and process 2 continues Unconditional locking Process 1 locks resource A Process 2 locks resource A Does not receive a condition report Process 2 waits in suspense (hangs) until lock is granted

15 Copyright © 2004 M. E. Kabay. All rights reserved. Serializable Transactions Prevent transactions affecting same records from overlapping Two-phase locking Can accumulate locks But once any lock is released, cannot get more until all are released Defines growing phase and shrinking phase More restrictive (and more common) strategy No locks released until COMMIT or ROLLBACK

16 Copyright © 2004 M. E. Kabay. All rights reserved. Deadlock (Deadly Embrace) A A B B Process 1 locks resource A unconditionally Process 2 locks resource B unconditionall y 1 locks B unconditionall y 2 locks A unconditionall y

17 Copyright © 2004 M. E. Kabay. All rights reserved. Preventing Deadlocks Deadlock is example of a race condition Will not necessarily occur Occurs by chance when specific events happen at specific time Always ensure that processes in applications LOCK RESOURCES IN SAME ORDER UNLOCK RESOURCES IN REVERSE ORDER Apply these principles to example on previous slide to see how they absolutely prevent deadlock

18 Copyright © 2004 M. E. Kabay. All rights reserved. Pessimistic Locking Strategy Assume collisions will occur and prevent conflicts Lock records Process transaction Release locks But very dangerous for performance if processing involves human interaction Not controllable Operator can leave resources locked and hang system Operator could go to lunch! DO NOT LOCK AROUND HUMAN INTERVENTION!

19 Copyright © 2004 M. E. Kabay. All rights reserved. Optimistic Locking Strategy Assume collisions will be rare and recover if they happen Read original data records Process transaction using buffers Lock original data records Check to see if original data have changed If no change, commit transaction & unlock If change, unlock & start over

20 Copyright © 2004 M. E. Kabay. All rights reserved. Optimistic Locking (1) Process Value1 Value3 Value2 Value3 Value1 DB Data buffers Same? Shows events when data change while processing is being carried out after initial READ

21 Copyright © 2004 M. E. Kabay. All rights reserved. Optimistic Locking (2) Process Value1 Value2 Value1 DB Data buffers Same? Value2 Observe events when there is no change in initial data during processing

22 Copyright © 2004 M. E. Kabay. All rights reserved. Optimistic vs Pessimistic Strategies Optimistic locking advantages Does not lock resources around human intervention Appropriate for Web / Internet transactions Especially important if lock granularity is large (e.g., entire DB or entire tables) Optimistic locking disadvantages If specific resource is in high demand (much contention for specific records) then can cause repeated access (thrashing) Can degrade individual and system performance

23 Copyright © 2004 M. E. Kabay. All rights reserved. Declaring Lock Characteristics Older programs often used specific calls to locking routines E.g., DBLOCK Passed parameters to set exact type of lock Conditional or not, granularity etc. Modern programming using DBMS uses transaction markers BEGIN, COMMIT, ROLLBACK Allows global definition of locking strategy DBMS handles details Can thus change locking globally without reprogramming

24 Copyright © 2004 M. E. Kabay. All rights reserved. Homework First, take a deep breath and assure yourself that you can do this. Study pages very carefully using SQ3R. Prepare for Thursdays class by using the survey-question phase of SQ3R on pages Then actually READ those pages. REQUIRED: By Tuesday 27 th April 2003: For 40 points, complete questions 11.1 through and include the questions with your answers

25 Copyright © 2004 M. E. Kabay. All rights reserved. DISCUSSION