Databases & Consistency. Database Relational databases : dominant information storage/retrieval system.

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 WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
Accessing data Transactions. Agenda Questions from last class? Transactions concurrency Locking rollback.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Fakultas Ilmu Komputer UI 1 Exercise A series of actions to be taken on the database such that either all actions are completed successfully, or none of.
Transaction Processing. Objectives After completing this lesson, you should be able to do the following: –Define transactions effectively for an application.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Avishai Wool lecture Introduction to Systems Programming Lecture 5 Deadlocks.
Transactions A process that reads or modifies the DB is called a transaction. It is a unit of execution of database operations. Basic JDBC transaction.
Jan. 2014Dr. Yangjun Chen ACS Database recovery techniques (Ch. 21, 3 rd ed. – Ch. 19, 4 th and 5 th ed. – Ch. 23, 6 th ed.)
ACID A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction, may change the DB from.
Durable starting state Durable, consistent, ending state Collection of resource actions Rollback Successful completion Abort The Transaction.
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
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Recovery Basics. Types of Recovery Catastrophic – disk crash –Backup from tape; redo from log Non-catastrophic: inconsistent state –Undo some operations.
Transactions and Recovery
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.
Distributed Deadlocks and Transaction Recovery.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
Databases & Consistency. Database Relational databases : dominant information storage/retrieval system.
Transaction Communications Yi Sun. Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction.
Transactions1 Unit of work on a database. Transactions2 Transactions, concept Logical unit of work on the database –Examples Transfer money from bank.
Databases Illuminated
HANDLING FAILURES. Warning This is a first draft I welcome your corrections.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
1 IRU Concurrency, Reliability and Integrity issues Geoff Leese October 2007 updated August 2008, October 2009.
Transactions CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
1 Transactions Chapter Transactions A transaction is: a logical unit of work a sequence of steps to accomplish a single task Can have multiple.
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
Concurrency Control in Database Operating Systems.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
Transactions -Fehily book - chap Mannino book - chap 15 (up to 15.2) Prof. Yitz Rosenthal.
The Relational Model1 Transaction Processing Units of Work.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Recovery.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
Software System Lab. Transactions Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various.
Recovery technique. Recovery concept Recovery from transactions failure mean data restored to the most recent consistent state just before the time of.
Module 11: Managing Transactions and Locks
Module Road Map The Scope of the Problem A range of potential problems Lost Updates User A reads a record User B reads the same record User A makes changes.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
11/12/97L-1 Transaction Processing Concepts Chapter
Advanced Database CS-426 Week 6 – Transaction. Transactions and Recovery Transactions A transaction is an action, or a series of actions, carried out.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
COMP 430 Intro. to Database Systems Transactions, concurrency, & ACID.
Concurrency Control in Distributed Database Systems Intelligent Information Systems Seminar 2 nd Sep 2015 Based on: Philip A. Bernstein and Nathan Goodman.
Jun-Ki Min. Slide Purpose of Database Recovery ◦ To bring the database into the last consistent stat e, which existed prior to the failure. ◦
Database recovery techniques
Database Recovery Techniques
DCL – Data Control Language
Databases & Consistency
Transaction Management
File Processing : Recovery
CS703 - Advanced Operating Systems
ACID PROPERTIES.
Transactions Properties.
Transaction Properties
Ch 21: Transaction Processing
Databases & Consistency
Database Processing: David M. Kroenke’s Chapter Nine: Part One
Databases & Consistency
Database Transactions
Databases & Consistency
Recovery System.
STRUCTURE OF PRESENTATION :
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Concurrency Control.
Presentation transcript:

Databases & Consistency

Database Relational databases : dominant information storage/retrieval system

Database Data stored in tables – Each row is a record – Columns define attributes

Consistency Consistent : no contradictions

Consistency Inconsistent : contradictions

How Do we Become Inconsistent? Only one row can be saved at a time…

How Do we Become Inconsistent? Only one row can be saved at a time…

How Do we Become Inconsistent? Only one row can be saved at a time… CRASH!!!!

How Do we Become Inconsistent? Two programs interact – Program 1: Make Rosina & Jingyi friends – Program 2: Make Matt & Jingi friends

How Do we Become Inconsistent? Two programs interact – Program 1: Make Rosina & Jingyi friends Make Rosina friend Jingyi – Program 2: Make Matt & Jingi friends

How Do we Become Inconsistent? Two programs interact – Program 1: Make Rosina & Jingyi friends Make Rosina friend Jingyi – Program 2: Make Matt & Jingi friends Make Rosina friend Jingyi

How Do we Become Inconsistent? Two programs interact – Program 1: Make Rosina & Jingyi friends Make Rosina friend Jingyi Check who Jingyi is friends with none – Program 2: Make Matt & Jingi friends Make Rosina friend Jingyi Check who Jingyi is friends with none

How Do we Become Inconsistent? Two programs interact – Program 1: Make Rosina & Jingyi friends Make Rosina friend Jingyi Check who Jingyi is friends with none Set Jingyi friend to none + Rosina – Program 2: Make Matt & Jingi friends Make Rosina friend Jingyi Check who Jingyi is friends with none

How Do we Become Inconsistent? Two programs interact – Program 1: Make Rosina & Jingyi friends Make Rosina friend Jingyi Check who Jingyi is friends with none Set Jingyi friend to none + Rosina – Program 2: Make Matt & Jingi friends Make Rosina friend Jingyi Check who Jingyi is friends with none Set Jingyi friend to none + Matt

Even Worse Zadie transfers $200 from savings to checking

Even Worse Zadie transfers $200 from savings to checking – Look at checking… decide it should be $600 – Look at savings… decide it should be $500 – Write change to checking – BOOM

To Do List Trick Make a list of what you intend to do and save it:

To Do List Trick Make a list of what you intend to do and save it:

To Do List Trick Make a list of what you intend to do and save it:

To Do List Trick Delete list when you are done:

To Do List Trick A crash…

Idempotent Idempotent action : same effect no matter how many times you execute it – "Change checking balance to $600" Non-idempotent – "Subtract $200 from checking"

To Do List If every instruction is: – Idempotent – Reversible : Know how to restore original state Can resume or reverse any partial transaction

OK smart guy… Zadie sends $200 to Pedro – Begin transaction – Change Zadie checking from $600 to $400 – Change Pedro checking from $150 to $350 – End transaction Pedro withdraws $100 – Begin transaction – Change Pedro checking from $150 to $50 – Spit out money – End transaction

OK smart guy… Zadie sends $200 to Pedro – Begin transaction – Change Zadie checking from $600 to $400 – Change Pedro checking from $150 to $350 – End transaction Pedro withdraws $100 – Begin transaction – Change Pedro checking from $150 to $50 – Spit out money – End transaction $400 $350

OK smart guy… Zadie sends $200 to Pedro – Begin transaction – Change Zadie checking from $600 to $400 – Change Pedro checking from $150 to $350 – End transaction Pedro withdraws $100 – Begin transaction – Change Pedro checking from $150 to $50 – Spit out money – End transaction $400 $50 Pedro got cheated!!!

OK smart guy… Zadie sends $200 to Pedro – Begin transaction – Change Zadie checking from $600 to $400 – Change Pedro checking from $150 to $350 – End transaction Pedro withdraws $100 – Begin transaction – Change Pedro checking from $150 to $50 – Spit out money – End transaction $50

OK smart guy… Zadie sends $200 to Pedro – Begin transaction – Change Zadie checking from $600 to $400 – Change Pedro checking from $150 to $350 – End transaction Pedro withdraws $100 – Begin transaction – Change Pedro checking from $150 to $50 – Spit out money – End transaction $400 $350 Pedro got $100 free!!!

Atomicity Atomic operation : indivisible / one unit – Never see results of half done transaction

Atomicity Transaction must LOCK all rows it will modify before starting

Atomicity Process A locks Marie Process B Pedro

Atomicity Process A locks Marie… now needs Pedro Process B Pedro… now needs Marie

Deadlock Busting Deadlock requires: – Mutual Exclusion, Hold & Wait, No Preemption

Deadlock Busting Deadlock requires: – Mutual Exclusion, Hold & Wait, No Preemption Database can preempt: – Roll back one transaction – Give up its locks – Make it restart AFTER other is complete

Replication Databases must be replicated – Redundancy – Speed Copies must remain consistent on the fly

Prepare Then Commit Trick Master DB initiates transaction

Prepare Then Commit Trick Master DB initiates transaction Asks each other DB to do same… waits for OK Prepare

Prepare Then Commit Trick Master DB initiates transaction Asks each other DB to do same… waits for OK Prepare Once everyone complete, sends signal to end transaction Commit

Prepare Then Commit Trick Master DB initiates transaction Asks each other DB to do same… waits for OK ERROR

Prepare Then Commit Trick Master DB initiates transaction Asks each other DB to do same… waits for OK ERROR Rollback instead of committing

Transactional Memory Current research area : Design regular software with transactional memory interactions