Databases & Consistency

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

TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
1 CPS216: Data-intensive Computing Systems Failure Recovery Shivnath Babu.
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.
1 CSIS 7102 Spring 2004 Lecture 8: Recovery (overview) Dr. King-Ip Lin.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
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
Databases & Consistency. Database Relational databases : dominant information storage/retrieval system.
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.
Transactions1 Unit of work on a database. Transactions2 Transactions, concept Logical unit of work on the database –Examples Transfer money from bank.
Chapterb19 Transaction Management Transaction: An action, or series of actions, carried out by a single user or application program, which reads or updates.
Databases Illuminated
HANDLING FAILURES. Warning This is a first draft I welcome your corrections.
Transaction processing Book, chapter 6.6. Problem: With a single user…. you run a query, you get the results, you run the next, etc. But database life.
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.
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.
Concurrency Control in Database Operating Systems.
Chapter 16 Recovery Yonsei University 1 st Semester, 2015 Sanghyun Park.
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.
Chapter 15: Transactions Loc Hoang CS 157B. Definition n A transaction is a discrete unit of work that must be completely processed or not processed at.
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.
Transaction Processing Concepts Muheet Ahmed Butt.
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
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
Jun-Ki Min. Slide Purpose of Database Recovery ◦ To bring the database into the last consistent stat e, which existed prior to the failure. ◦
1 Advanced Database Systems: DBS CB, 2 nd Edition Recovery Ch. 17.
Database recovery techniques
Database Recovery Techniques
DCL – Data Control Language
File Processing : Recovery
Database Systems (資料庫系統)
ACID PROPERTIES.
Transactions Properties.
Ch 21: Transaction Processing
Databases & Consistency
The PROCESS of Queries John Deardurff
Databases & Consistency
Database Transactions
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
Databases & Consistency
Transaction Processing Concepts
Recovery System.
The PROCESS of Queries John Deardurff
Topic 15 Lesson 1 – Action queries
Updating Databases With Open SQL
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.
Updating Databases With Open SQL
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 Matt 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

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

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 Set Jingyi friend to none + Matt

Even Worse Zadie transfers $200 from checking to savings

Even Worse Zadie transfers $200 from checking to savings 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 Pedro withdraws $100 Begin transaction Change Zadie checking from $600 to $400 Change Pedro checking from $150 to $350 End transaction Pedro withdraws $100 Change Pedro checking from $150 to $50 Spit out money

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

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

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

OK smart guy… Zadie sends $200 to Pedro Pedro withdraws $100 Begin transaction Change Zadie checking from $600 to $400 Change Pedro checking from $150 to $350 End transaction Pedro withdraws $100 Change Pedro checking from $150 to $50 Spit out money $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 Want to transfer money from Marie to Pedro

Deadlock Two Programs both trying to transfer money Process A locks Marie Process B Pedro

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

Deadlock Busting Database can resolve: 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